Trying to use __construct inside a controller to assign some variable but it keeps throwing errors. Hoping that someone can lead me in the right direction.
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';
}