嘗試在控制器內部使用__construct來分配一些變量,但它一直拋出錯誤。希望有人能帶領我走向正確的方向。Kohana 3控制器構造
class Controller_Mobile extends Controller {
public function __construct()
{
parent::__construct();
$iphoneDetect = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone");
$touchDetect = strpos($_SERVER['HTTP_USER_AGENT'],"iPod");
$blackberry = strpos ($_SERVER['HTTP_USER_AGENT'], 'blackberry');
$android = strpos ($_SERVER['HTTP_USER_AGENT'], 'android');
$iphoneDetect = true;
if ($iphoneDetect == true || $touchDetect == true)
{
$directory = "mobile/iphone";
}
else if($android == true)
{
$directory = "mobile/android";
}
}
public function action_index()
{
$this->request->response = 'I am mobile';
}
什麼是錯誤? – irishbuzz 2010-09-08 19:58:03