Re: How do I enable $_SERVER['HTTP_X_WAP_PROFILE'] or $_SERVER['HTTP_PROFILE']
| From: | Stuart Dallas | Date: | Thu, 04 Aug 2011 07:46:30 +0000 |
| Subject: | Re: How do I enable $_SERVER['HTTP_X_WAP_PROFILE'] or $_SERVER['HTTP_PROFILE'] | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-314335@lists.php.net to get a copy of this message | ||
On 3 Aug 2011, at 21:07, Daevid Vincent wrote:
> I'm working on a mobile site and from the various searches and reading (and
> even code fragments I've inherited for the project), they make reference to:
>
> $_SERVER['HTTP_X_WAP_PROFILE'] and a fallback $_SERVER['HTTP_PROFILE']
>
> However, when I hit a phpinfo(); page using both an Android MyTouch 3G (2.2)
> and an Apple iPhone 3G, there are nothing even close to those. All of the
> 'HTTP_X_*' headers are absent and there is no HTTP_PROFILE either.
>
>
> http://www.dpinyc.com/literature/resources/code-bank/php-lightweight-device-
> detection/
> http://mobiforge.com/developing/blog/useful-x-headers
> http://blog.svnlabs.com/tag/_serverhttp_x_wap_profile/
>
>
> Do I need to enable something in Apache or PHP??
>
> PHP Version 5.3.6
> Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
> with Xdebug v2.0.5, Copyright (c) 2002-2008, by Derick Rethans
>
> and
>
> $ httpd -v
> Server version: Apache/2.2.17 (FreeBSD)
I may be wrong, but as I understand it those headers are for older WAP browsers, not modern
mobile-based browsers which are HTML-capable. The best way I've found to detect mobile devices
is to examine the user agent header. While it's not 100% reliable it's the best method
available.
This is the function I've used in the past to detect mobile devices: https://gist.github.com/1124666. I haven't used it
for a little while so there are probably new devices out there that it can't detect but it
should give you a good starting point.
-Stuart
--
Stuart Dallas
3ft9 Ltd
http://3ft9.com/