php symfony 1.1检测android或iphone(php symfony 1.1 detect android or iphone)
我想知道它是iphone还是android手机,我使用下面的代码进行检测,但这显示为Android或iphone设备的Mobile .....
但需要像Android / iphone / ipad ....
public function preExecute() { ... $context = $this->getContext(); $request = $context->getRequest(); $response = $context->getResponse(); print_r($request->getHttpHeader('User-Agent')); .... }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')); .... }最满意答案
你可以用这个:
$ua = strtolower($request->getHttpHeader('User-Agent')); if(stripos($ua,'android') !== false) { //android }else if(stripos($ua,'iPhone') !== false) { //iphone }else{ //other browser }PS我建议你尽可能升级到symfony 1.4! 它提供了一个
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
更多推荐
发布评论