简体   繁体   中英

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

what is the difference between $this->request->param() and $this->request->post() in kohana 3.2?

Somebody explain me briefly.

Thanks

Suppose you have URL like this: http://example.com/store/books/computer/martin_fowler with routing defined as follows:

Route::set('books', '<controller>/<action>(/<product>(/<category>(/<author>)))')
        ->defaults(array(
            'controller' => 'store',
            'action' => '',
        ));

$this->request->param() this will return:

array (
  'product' => 'books', 
  'category' => 'computer',
  'author' => 'martin_fowler',
)

$this->request->post() will return $_POST data.

Both methods will return NULL if the key is not found:

$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

In Kohana

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

returns post data like submit form.

$this->request->param()

returns posted as well as get data which is send from $_POST and $_GET.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM