php symfony 1.1检测android或iphone(php symfony 1.1 detect android or iphone)

编程入门 行业动态 更新时间:2024-10-25 06:22:17
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

更多推荐

本文发布于:2023-07-24 10:46:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1244945.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:symfony   php   detect   iphone   android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!