我已經在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 is null');
$this->response->body($content);
}
}
寫了一個樣本控制器,但是當我試圖打網址http://localhost/k/album?id=4 我收到NULL值。 如何使用request-> param訪問kohana中的請求變量,而不使用$ _GET和$ _POST方法?
爲什麼你傳遞第二個參數','value是null''? – 2011-04-11 13:06:50
如果值不存在,那麼它是選項參數。它將用該值替換該值。 如果值不存在,第二個值是默認值。 – 2011-04-11 13:09:00
什麼是你的Kohana版本?使用'$ this-> request-> query('id')'如果使用Ko3.1 – biakaveron 2011-04-11 14:06:02