php - how to use $this->request->param of Kohana to get request variables -


i have written sample controller in kohana

    <?php  defined('syspath') or die('no direct access allowed.');  class controller_album extends controller {    public function action_index() {     $content=$this->request->param('id','value null');        $this->response->body($content);   }  } 

but when trying hit url http://localhost/k/album?id=4 getting null value. how can access request variable in kohana using request->param , without using $_get , $_post method ?

in kohana v3.1+ request class has query() , post() methods. work both getter , setter:

// $_post data $data = $this->request->post(); // returns $_get['foo'] or null if not exists $foo = $this->request->query('foo');   // set $_post['foo'] value executing request $request->post('foo', 'bar'); // or put array of vars. existing data deleted! $request->query(array('foo' => 'bar')); 

but remember setting get/post data not overload current $_get/$_post values. sent after request executing ($request->execute() call).


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -