<?php
namespace app\web\controller;
use Timo\Core\Controller;
Class Document extends Controller
{
public function show($id = 0)
{
echo $id;
}
}
URL: http://www.timophp.com/document/show/100/
访问上面的URL,会打印出100,就相当于把url中show后面的100绑定到了show方法的$id参数上面,参数名称自定义
例子:http://www.timophp.com/document/show/100/?type=1&from=index
$type = Request::get('type');
$type = Request::get('type', 0);
$type = Request::get('type', 0, 'intval');
默认值可不传,默认为0,等价于Request::get(参数名, 0, 'interval')
Request::getInt('type')
默认值可不传,默认为空字符串,等价于Request::get(参数名, '', 'trim')
Request::getString('name')
Request::post([参数名], [默认值], [过滤函数]);
Request::postInt(参数名, [默认值]);
Request::postString(参数名, [默认值]);
Request::post()获取整个post内容
<form action="http://www.timophp.com/document/show/100/" method="POST">
<input type="text" name="email" />
<input type="text" name="password" />
<input type="submit" value="提交" />
</form>
$type = Request::post('email');
$type = Request::post('email', '');
$type = Request::post('password', '', 'trim');
Request::json([参数名], [默认值], [过滤函数]);
Request::jsonInt(参数名, [默认值]);
Request::jsonString(参数名, [默认值]);
Request::json()获取整个json内容