![](/img/trans.png)
[英]how to use $this->request->param of Kohana to get request variables
[英]$this->request->param() and $this->request->post() in kohana 3.2
kohana 3.2中的$this->request->param()
和$this->request->post()
有什么区别?
有人简短地向我解释。
谢谢
假设您具有这样的URL: http : //example.com/store/books/computer/martin_fowler ,其路由定义如下:
Route::set('books', '<controller>/<action>(/<product>(/<category>(/<author>)))')
->defaults(array(
'controller' => 'store',
'action' => '',
));
$this->request->param()
将返回:
array (
'product' => 'books',
'category' => 'computer',
'author' => 'martin_fowler',
)
$this->request->post()
将返回$_POST
数据。
如果找不到密钥,则这两种方法都将返回NULL:
$this->request->param('xxx') // NULL
$this->request->param('author') // martin_fowler
$this->request->post('id') // Some id value in $_POST or NULL if id doesn't exist in $_POST
在Kohana
$data = $this->request->post();
// get $_POST data
返回帖子数据,例如提交表单。
$this->request->param()
返回发布的数据以及从$ _POST和$ _GET发送的数据。
在路由过程之后,Param获取分配给请求的请求参数,而post获取原始数据POST。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.