$ this-> request-> param()和$ this-> request-> post()in kohana 3.2

时间:2013-07-02 05:24:50

标签: php mysql kohana kohana-3

kohana 3.2中$this->request->param()$this->request->post()之间有什么区别?

有人简要解释一下。

由于

3 个答案:

答案 0 :(得分:1)

假设您有这样的网址: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

答案 1 :(得分:0)

在Kohana

$data = $this->request->post();
// get $_POST data

返回提交表单等帖子数据。

$this->request->param()

返回发布以及获取从$ _POST和$ _GET发送的数据。

答案 2 :(得分:0)

Param在路由过程之后获取分配给请求的请求参数,而post获取POST的原始数据。

相关问题