Question

i want to know whether it is a iphone or android phone, i used below code for detection, But this displaying as Mobile for both Android or iphone devices.....

But need like Android/iphone/ipad....

public function preExecute() {
...
    $context    = $this->getContext();
            $request    = $context->getRequest();
            $response   = $context->getResponse();

            print_r($request->getHttpHeader('User-Agent'));
....
}
Was it helpful?

Solution

You could use this:

$ua = strtolower($request->getHttpHeader('User-Agent'));
if(stripos($ua,'android') !== false) {
    //android
}else if(stripos($ua,'iPhone') !== false) {
    //iphone
}else{
    //other browser
}

P.S. I would recommend that you upgrade to symfony 1.4 if possible! It provides a

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top