0

kohana 3.2$this->request->param()和in有什么区别?$this->request->post()

有人简要解释一下。

谢谢

4

3 回答 3

1

假设您有这样的 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
于 2013-07-02T11:11:31.653 回答
0

位于科哈纳

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

返回提交表单等发布数据。

$this->request->param()

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

于 2013-07-02T05:29:08.773 回答
0

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

于 2013-07-02T05:30:23.497 回答