Re: [PHP] Headers on smart phone browsers

2012-02-07 Thread Ashley Sheridan
On Mon, 2012-02-06 at 18:09 -0600, Donovan Brooke wrote:

 Mari Masuda wrote:
 [snip]
  For a concrete example of responsive design in action, point your browser 
  to http://www.sasquatchfestival.com/ and then slowly make the window 
  wider/skinnier to see how the design adapts to different viewport sizes.
 
 
 Very nice... makes for an easy display to a wide range of circumstances 
 I think.. especially image resizing (in the blog example), which looks 
 pretty smooth. But, in both the examples, it appears it can produce a 
 choppy user experience when resizing the window as well...
 
 I suppose that resizing could be viewed as one of those 80/20 percent 
 rule things.. meaning, window resizing is probably not a prevalent 
 action for a user and it could be argued that one shouldn't code a site 
 worrying too much about dynamic window resizing... but then there is a 
 form of resizing, which is turning your iPAD to landscape view, etc..
 
 I suppose one could probably still do some UA detection and serve up 
 content based on the type of UA (ie. mobile, IE, game-based) and at 
 that point, still incorporate responsive web design, but to that 
 more-limited-category of UA's.
 
 Donovan
 
 
 
 
 
 -- 
 D Brooke
 


There is only one drawback to using CSS media queries to alter the way a
page is displayed on different resolutions, and that is that any media
(i.e. background images, etc) referenced in a stylesheet is downloaded,
regardless of if it is ever used.

So if you have two background images for the body, one large for nice
wide screens, and a smaller one for smaller screens, they will both be
downloaded by the browser. The way around this is to use Javascript to
load only the stylesheets required, but then you're relying on
Javascript and you don't need media queries. It's a pain finding the
right balance.

-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Headers on smart phone browsers

2012-02-07 Thread Marc Guay
 There is only one drawback to using CSS media queries to alter the way a
 page is displayed on different resolutions, and that is that any media
 (i.e. background images, etc) referenced in a stylesheet is downloaded,
 regardless of if it is ever used.

Another one worth mentionning is that a lot of mobile devices still in
use do not support media queries - their being a relatively recent
development.  Same goes for javascript, even if it claims to support
it.  Older Blackberrys claim JS support but fail miserably in real
life.

Marc

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Headers on smart phone browsers

2012-02-07 Thread Tedd Sperling
On Feb 6, 2012, at 4:01 PM, Stuart Dallas wrote:
 Generally speaking you're better off with a design that automatically adapts 
 to the viewport on which it's being displayed. While there's more than one 
 reason for this, the overriding reason is that the same software (i.e. the 
 same user agent) could be running on any size of device, from watch to huge 
 flat panel screen on a wall.
 
 I think the world needs to move on from is it a mobile device or not to 
 accepting the reality which is that the browser / OS is irrelevant, and that 
 the way your site renders should be purely based upon the size of the 
 display. Responsive designs such as that described in the A List Apart 
 article Mari posted are fantastic tools for achieving this goal.
 
 -Stuart
 

Agreed. Not only the size of the display -- but what's a size of a pixel?

http://www.alistapart.com/articles/a-pixel-identity-crisis/

Presentation is a difficult problem to solve, but I don't think PHP enters into 
the equation. From my view, the only thing that PHP can do is device-sniff, 
which is clearly a losing proposition.

I believe that a presentation solution will be solved by presentation languages 
(i.e, client-side).

Cheers,

tedd


_
t...@sperling.com
http://sperling.com



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Headers on smart phone browsers

2012-02-06 Thread Jim Giner
Nice article!!

You should read up on responsive web design. 
http://www.alistapart.com/articles/responsive-web-design/ should get you 
started.  HTH!= 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Headers on smart phone browsers

2012-02-06 Thread Marc Guay
 1) Do smart phones use the same browsers as the desktop, or do they have
 their own stripped down versions of browsers?

Different browsers, some of which are worse than IE (see Blackberry).


 2) When a browser broadcasts its header telling the server what kind of
 browser is involved, do they broadcast anything in the header to
 indicate that they're being run on a smart phone?

Nothing so specific or easy to identify as i am a smartphone.
Depending on your target audience, simple regex checks for the strings
iphone, android, etc. can do the trick, but if you want specific
details about the device...


 3) Bonus question: Is there a preferred method amongst coders to
 determine what type of environment is being browsed from, so as to serve
 up the proper type of page (desktop or smart phone version of a
 webpage)?

... the WURFL database and things akin to it or based on / stolen from
it can help parse the header string and return a plethora of
information about it (screen size, AJAX ability, markup capacity,
etc).

Marc

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Headers on smart phone browsers

2012-02-06 Thread Donovan Brooke

Paul M Foster wrote:

This is sort of obliquely related to PHP.

I don't have a smart phone, but I need to know a couple of things:

1) Do smart phones use the same browsers as the desktop, or do they have
their own stripped down versions of browsers?

2) When a browser broadcasts its header telling the server what kind of
browser is involved, do they broadcast anything in the header to
indicate that they're being run on a smart phone?

3) Bonus question: Is there a preferred method amongst coders to
determine what type of environment is being browsed from, so as to serve
up the proper type of page (desktop or smart phone version of a
webpage)?

Paul


Hi Paul, I think this is a great PHP conversation.. and I don't 
understand why GOTO threads always get way more replies than something 
like this ;-)


Diverse User Agent compatibility is going to be more and more of a 
challenge for us.. gone are the days of a few known browsers that are 
viewing our sites.  From bots, to browsers, to mobile devices, to game 
UA's, to app UA's.., to IE's stubborn outlook on the web... the idea of 
user experience is growing complicated! ;-)


I really liked Mari's posted link to the a list apart blog about 
responsive web design using media query (CSS).. however, it seems to 
me that it takes the use of many languages and techniques in many cases 
to get the job done... user agent serving (using PHP or JS or alike), 
flexible CSS and web design, and a keen eye on your target audience may 
all play apart.


However, this is a PHP list.. and I think we can better approach this 
topic by limiting our scope to talk about how PHP could be useful.


My first question, being that my first language is not PHP, is; is their 
any core PHP mobile detection functions/tools that exist?


I have a running list of mobile UA's that I picked up somewhere that I 
often use and edit to distribute content accordingly. I also have a PHP 
mobile detection script that I picked up somewhere. I'm sure these 
things can be found via google as well. The problem, as Mari's link 
suggests, is that UA list's and browser sniffing scripts need 
maintaining quite regularly, since mobile UA's are being added on a 
weekly basis perhaps.


Many of my projects do some PC UA (browser) sniffing.. especially for 
IE., as IE has it's own system that it uses for how to render content.


Anyway, I'm happy to share what I have.. but like I said, PHP is not my 
first language, so I am interested to see what the more established 
PHP'ers may have to say.


Donovan



--
D Brooke

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Headers on smart phone browsers

2012-02-06 Thread Adam Richardson
On Mon, Feb 6, 2012 at 12:58 AM, Paul M Foster pa...@quillandmouse.comwrote:

 This is sort of obliquely related to PHP.

 I don't have a smart phone, but I need to know a couple of things:

 1) Do smart phones use the same browsers as the desktop, or do they have
 their own stripped down versions of browsers?


Both, although more and more smart phones join the ranks of the
desktop-quality browser every day (iPhone and Android both have very
capable browsers, with the iPhone's omission of flash support being the
biggest difference between these two.)



 2) When a browser broadcasts its header telling the server what kind of
 browser is involved, do they broadcast anything in the header to
 indicate that they're being run on a smart phone?


Yes, but that gets complicated quickly:
http://www.zytrax.com/tech/web/mobile_ids.html



 3) Bonus question: Is there a preferred method amongst coders to
 determine what type of environment is being browsed from, so as to serve
 up the proper type of page (desktop or smart phone version of a
 webpage)?


To supplement the alistapart link already mentioned, here's another recent
writeup:
http://dev.opera.com/articles/view/how-to-serve-the-right-content-to-mobile/

I develop mobile games and websites, and I never use the User Agent to
alter site/presentation. Media queries and types are the way I handle this
(sometimes creating separate mobile resources, but most of the time
creating designs that adapt accordingly.)

All this to say, I don't use PHP to handle this aspect of the development.

Adam


-- 
Nephtali:  A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com


Re: [PHP] Headers on smart phone browsers

2012-02-06 Thread Ashley Sheridan
On Mon, 2012-02-06 at 14:28 -0600, Donovan Brooke wrote:

 Paul M Foster wrote:
  This is sort of obliquely related to PHP.
 
  I don't have a smart phone, but I need to know a couple of things:
 
  1) Do smart phones use the same browsers as the desktop, or do they have
  their own stripped down versions of browsers?
 
  2) When a browser broadcasts its header telling the server what kind of
  browser is involved, do they broadcast anything in the header to
  indicate that they're being run on a smart phone?
 
  3) Bonus question: Is there a preferred method amongst coders to
  determine what type of environment is being browsed from, so as to serve
  up the proper type of page (desktop or smart phone version of a
  webpage)?
 
  Paul
 
 Hi Paul, I think this is a great PHP conversation.. and I don't 
 understand why GOTO threads always get way more replies than something 
 like this ;-)
 
 Diverse User Agent compatibility is going to be more and more of a 
 challenge for us.. gone are the days of a few known browsers that are 
 viewing our sites.  From bots, to browsers, to mobile devices, to game 
 UA's, to app UA's.., to IE's stubborn outlook on the web... the idea of 
 user experience is growing complicated! ;-)
 
 I really liked Mari's posted link to the a list apart blog about 
 responsive web design using media query (CSS).. however, it seems to 
 me that it takes the use of many languages and techniques in many cases 
 to get the job done... user agent serving (using PHP or JS or alike), 
 flexible CSS and web design, and a keen eye on your target audience may 
 all play apart.
 
 However, this is a PHP list.. and I think we can better approach this 
 topic by limiting our scope to talk about how PHP could be useful.
 
 My first question, being that my first language is not PHP, is; is their 
 any core PHP mobile detection functions/tools that exist?
 
 I have a running list of mobile UA's that I picked up somewhere that I 
 often use and edit to distribute content accordingly. I also have a PHP 
 mobile detection script that I picked up somewhere. I'm sure these 
 things can be found via google as well. The problem, as Mari's link 
 suggests, is that UA list's and browser sniffing scripts need 
 maintaining quite regularly, since mobile UA's are being added on a 
 weekly basis perhaps.
 
 Many of my projects do some PC UA (browser) sniffing.. especially for 
 IE., as IE has it's own system that it uses for how to render content.
 
 Anyway, I'm happy to share what I have.. but like I said, PHP is not my 
 first language, so I am interested to see what the more established 
 PHP'ers may have to say.
 
 Donovan
 
 
 
 -- 
 D Brooke
 


Keeping a PHP angle to this, have you looked at using an up-to-date
browscap.ini file with PHP? Basically, you can use that to read in the
raw user agent string from the browser, and it then finds a matching
entry in the ini file and gives you back some values about what it can
assume about that device, such as whether it is known to support Java
(although this is something you should be careful of, as it only tells
you if it's is supported, not if there is an available JVM), if it is a
mobile or search bot, what version of CSS it should support, etc. I use
it myself in a personal web stats script, and as long as you keep the
copy of the ini file recent, you should be OK.

-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Headers on smart phone browsers

2012-02-06 Thread Stuart Dallas
On 6 Feb 2012, at 05:58, Paul M Foster wrote:

 This is sort of obliquely related to PHP.
 
 I don't have a smart phone, but I need to know a couple of things:

There are simulators available for most smartphones.

 1) Do smart phones use the same browsers as the desktop, or do they have
 their own stripped down versions of browsers?

The trend is certainly moving towards full desktop capability, but personally I 
still think that if you expect a significant amount of traffic from mobile 
devices then your site should adapt accordingly.

 2) When a browser broadcasts its header telling the server what kind of
 browser is involved, do they broadcast anything in the header to
 indicate that they're being run on a smart phone?

Yes, but there's no standard at the moment so detection requires something 
similar to https://gist.github.com/1124666. That code is pretty old, and I 
can't remember where I got it, but at the time it worked really well.

 3) Bonus question: Is there a preferred method amongst coders to
 determine what type of environment is being browsed from, so as to serve
 up the proper type of page (desktop or smart phone version of a
 webpage)?

Generally speaking you're better off with a design that automatically adapts to 
the viewport on which it's being displayed. While there's more than one reason 
for this, the overriding reason is that the same software (i.e. the same user 
agent) could be running on any size of device, from watch to huge flat panel 
screen on a wall.

I think the world needs to move on from is it a mobile device or not to 
accepting the reality which is that the browser / OS is irrelevant, and that 
the way your site renders should be purely based upon the size of the display. 
Responsive designs such as that described in the A List Apart article Mari 
posted are fantastic tools for achieving this goal.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Headers on smart phone browsers

2012-02-06 Thread Adam Richardson
On Mon, Feb 6, 2012 at 3:50 PM, Adam Richardson simples...@gmail.comwrote:

 On Mon, Feb 6, 2012 at 12:58 AM, Paul M Foster pa...@quillandmouse.comwrote:

 This is sort of obliquely related to PHP.

 I don't have a smart phone, but I need to know a couple of things:

 1) Do smart phones use the same browsers as the desktop, or do they have
 their own stripped down versions of browsers?


 Both, although more and more smart phones join the ranks of the
 desktop-quality browser every day (iPhone and Android both have very
 capable browsers, with the iPhone's omission of flash support being the
 biggest difference between these two.)



 2) When a browser broadcasts its header telling the server what kind of
 browser is involved, do they broadcast anything in the header to
 indicate that they're being run on a smart phone?


 Yes, but that gets complicated quickly:
 http://www.zytrax.com/tech/web/mobile_ids.html



 3) Bonus question: Is there a preferred method amongst coders to
 determine what type of environment is being browsed from, so as to serve
 up the proper type of page (desktop or smart phone version of a
 webpage)?


 To supplement the alistapart link already mentioned, here's another recent
 writeup:

 http://dev.opera.com/articles/view/how-to-serve-the-right-content-to-mobile/



Apologies, I sent the wrong link last time:
http://dev.opera.com/articles/view/the-mobile-web-optimization-guide/

Adam


Re: [PHP] Headers on smart phone browsers

2012-02-06 Thread Marc Guay
 the way your site renders should be purely based upon the size of the display.

Although I mostly agree with this statement, it ignores the most
interesting aspects of mobile technology, such as being able to ask
the user for their GPS location and deliver content accordingly.  I
worked on some real estate websites that would show the user the
houses for sale within a certai distance from where they were
standing, and then leverage Google Maps for a get directions from
where you are feature.

The Mobile Web list has had some interesting discussions regarding this stuff...

http://groups.yahoo.com/group/mobile-web/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Headers on smart phone browsers

2012-02-06 Thread Stuart Dallas
On 6 Feb 2012, at 21:12, Marc Guay wrote:

 the way your site renders should be purely based upon the size of the 
 display.
 
 Although I mostly agree with this statement, it ignores the most
 interesting aspects of mobile technology, such as being able to ask
 the user for their GPS location and deliver content accordingly.  I
 worked on some real estate websites that would show the user the
 houses for sale within a certai distance from where they were
 standing, and then leverage Google Maps for a get directions from
 where you are feature.
 
 The Mobile Web list has had some interesting discussions regarding this 
 stuff...
 
 http://groups.yahoo.com/group/mobile-web/

On the contrary, my statement dealt only with the way a site renders, not the 
content it renders. We should definitely be taking advantage of the additional 
features of mobile devices where it makes sense because that's where the real 
game-changing power lies.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Headers on smart phone browsers

2012-02-06 Thread Paul M Foster
On Mon, Feb 06, 2012 at 02:28:42PM -0600, Donovan Brooke wrote:

 Paul M Foster wrote:
 This is sort of obliquely related to PHP.
 
 I don't have a smart phone, but I need to know a couple of things:
 
 1) Do smart phones use the same browsers as the desktop, or do they have
 their own stripped down versions of browsers?
 
 2) When a browser broadcasts its header telling the server what kind of
 browser is involved, do they broadcast anything in the header to
 indicate that they're being run on a smart phone?
 
 3) Bonus question: Is there a preferred method amongst coders to
 determine what type of environment is being browsed from, so as to serve
 up the proper type of page (desktop or smart phone version of a
 webpage)?
 
 Paul
 
 Hi Paul, I think this is a great PHP conversation.. and I don't
 understand why GOTO threads always get way more replies than
 something like this ;-)

See religion (n), defs 1-10.

 
 Diverse User Agent compatibility is going to be more and more of a
 challenge for us.. gone are the days of a few known browsers that
 are viewing our sites.  From bots, to browsers, to mobile devices,
 to game UA's, to app UA's.., to IE's stubborn outlook on the web...
 the idea of user experience is growing complicated! ;-)

Well, cursory research shows there are at least 12 different major
layout engines underneath modern browsers. Multiply that by versions of
same, different OSes on which each run, versions of the OSes themselves,
etc. etc. etc. I don't envy the job of any piece of code which tries to
analyze all this. Plus, I believe that in the future, handhelds
(specifically smart phones) will approach desktops in screen
resolution.

 
 I really liked Mari's posted link to the a list apart blog about
 responsive web design using media query (CSS).. however, it
 seems to me that it takes the use of many languages and techniques
 in many cases to get the job done... user agent serving (using PHP
 or JS or alike), flexible CSS and web design, and a keen eye on your
 target audience may all play apart.

Not to mention that W3C has all but abandoned its efforts to standardize
HTML5. They will likely follow the path of browsers in simple de facto
standardization.

 
 However, this is a PHP list.. and I think we can better approach
 this topic by limiting our scope to talk about how PHP could be
 useful.
 
 My first question, being that my first language is not PHP, is; is
 their any core PHP mobile detection functions/tools that exist?

From what I've seen, only the get_browser() function, which depends on
the existence of a browsecap file, which may or may not be installed on
your system. And if it is, it's 300K in size, and introduces significant
latency to page loads as a result.

 
 I have a running list of mobile UA's that I picked up somewhere that
 I often use and edit to distribute content accordingly. I also have
 a PHP mobile detection script that I picked up somewhere. I'm sure
 these things can be found via google as well. The problem, as Mari's
 link suggests, is that UA list's and browser sniffing scripts need
 maintaining quite regularly, since mobile UA's are being added on a
 weekly basis perhaps.

I suspect that's more as a result of everything sniffer scripts do. They
don't just detect the platform, but a variety of other things as well.

 
 Many of my projects do some PC UA (browser) sniffing.. especially
 for IE., as IE has it's own system that it uses for how to render
 content.
 
 Anyway, I'm happy to share what I have.. but like I said, PHP is not
 my first language, so I am interested to see what the more
 established PHP'ers may have to say.

How about this: those of you with iPhones, Androids and the like, point
your phones at a page which reports $_SERVER['HTTP_USER_AGENT'] (like a
page which runs the phpinfo() function), and post what you get back from
that exercise and what device made the query. I'd like to see if there
is anything significant which indicates handheld platforms.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Headers on smart phone browsers

2012-02-06 Thread Paul M Foster
On Mon, Feb 06, 2012 at 09:02:34PM +, Ashley Sheridan wrote:

[snip]

 
 
 Keeping a PHP angle to this, have you looked at using an up-to-date
 browscap.ini file with PHP? Basically, you can use that to read in the
 raw user agent string from the browser, and it then finds a matching
 entry in the ini file and gives you back some values about what it can
 assume about that device, such as whether it is known to support Java
 (although this is something you should be careful of, as it only tells
 you if it's is supported, not if there is an available JVM), if it is a
 mobile or search bot, what version of CSS it should support, etc. I use
 it myself in a personal web stats script, and as long as you keep the
 copy of the ini file recent, you should be OK.

The issue with this (according to the get_browser() docs) is that the
browsecap file is 300K long, will get longer, and significantly slows
loading of your applications. Moreover, the parsing of the UA string and
other data is far more extensive than anything I'd want or could use.
The only thing I'd want to know is whether I'm serving pages to a
handheld or desktop device.

From what I've seen, pages built for handheld devices (see, for example,
yahoo.mobi) are considerably stripped down, often with no CSS styling.
For now, if I have to make the decision on whether to serve up desktop
or handheld versions of a page, all I want to know is a yes or no answer
to the question of, Is this a handheld? The native PHP get_browser()
function appears to be overkill for that, and may, in fact be
insufficient.

That was the origin of the original questions-- was there some
definitive way of knowing the platform when the page request came in.
And from all the research I've done, the answer is, No. The UA string
may not work as intended. There are javascript sniffers and CSS
triggers, but neither are they definitive. For example, the CSS
triggers test for resolution or screen width or the like. This is fine,
so long as handhelds remain at crappy resolutions. But I don't expect
that to be the case forever. 

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Headers on smart phone browsers

2012-02-06 Thread Donovan Brooke

Ashley Sheridan wrote:
[snip]

Keeping a PHP angle to this, have you looked at using an up-to-date
browscap.ini file with PHP? Basically, you can use that to read in the
raw user agent string from the browser, and it then finds a matching
entry in the ini file and gives you back some values about what it can
assume about that device, such as whether it is known to support Java
(although this is something you should be careful of, as it only tells
you if it's is supported, not if there is an available JVM), if it is a
mobile or search bot, what version of CSS it should support, etc. I use
it myself in a personal web stats script, and as long as you keep the
copy of the ini file recent, you should be OK.



Interesting, I will check that out.

Donovan




--
D Brooke

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Headers on smart phone browsers

2012-02-06 Thread Donovan Brooke

Stuart Dallas wrote:

On 6 Feb 2012, at 21:12, Marc Guay wrote:


the way your site renders should be purely based upon the size of the display.


Although I mostly agree with this statement, it ignores the most
interesting aspects of mobile technology, such as being able to ask
the user for their GPS location and deliver content accordingly.  I
worked on some real estate websites that would show the user the
houses for sale within a certai distance from where they were
standing, and then leverage Google Maps for a get directions from
where you are feature.

The Mobile Web list has had some interesting discussions regarding this stuff...

http://groups.yahoo.com/group/mobile-web/


On the contrary, my statement dealt only with the way a site renders, not the 
content it renders. We should definitely be taking advantage of the additional 
features of mobile devices where it makes sense because that's where the real 
game-changing power lies.

-Stuart




Right, the OP doesn't state the purpose exactly (design, function, 
etc..)... but even if it was design, as noted in Mari's link toward the 
bottom, responsive web design is not supported the same in all 
platforms... this is why I think, in many situations, a mix of UA 
detection and versatile design is still relevant (even in design).


Donovan


--
D Brooke

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Headers on smart phone browsers

2012-02-06 Thread Paul M Foster
On Mon, Feb 06, 2012 at 04:04:28PM -0500, Adam Richardson wrote:

On Mon, Feb 6, 2012 at 3:50 PM, Adam Richardson [1]simples...@gmail.com
wrote:
 
  On Mon, Feb 6, 2012 at 12:58 AM, Paul M Foster
  [2]pa...@quillandmouse.com wrote:
 
This is sort of obliquely related to PHP.
 
I don't have a smart phone, but I need to know a couple of things:
 
1) Do smart phones use the same browsers as the desktop, or do they
have
their own stripped down versions of browsers?
 
  Both, although more and more smart phones join the ranks of the
  desktop-quality browser every day (iPhone and Android both have very
  capable browsers, with the iPhone's omission of flash support being the
  biggest difference between these two.)
  �
 
2) When a browser broadcasts its header telling the server what kind
of
browser is involved, do they broadcast anything in the header to
indicate that they're being run on a smart phone?
 
  Yes, but that gets complicated quickly:
  [3]http://www.zytrax.com/tech/web/mobile_ids.html
  �

This gets directly at the answer, but also proves that there's no
practical way of using the information. There are simply too many
variations, and more to come. Great reference. I didn't find it in my
prior research on Google.

 
3) Bonus question: Is there a preferred method amongst coders to
determine what type of environment is being browsed from, so as to
serve
up the proper type of page (desktop or smart phone version of a
webpage)?
 
  To supplement the alistapart link already mentioned, here's another
  recent writeup:
  
 [4]http://dev.opera.com/articles/view/how-to-serve-the-right-content-to-mobile/
 
Apologies, I sent the wrong link last time:
[5]http://dev.opera.com/articles/view/the-mobile-web-optimization-guide/
Adam

Thanks,

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Headers on smart phone browsers

2012-02-06 Thread Paul M Foster
On Mon, Feb 06, 2012 at 09:01:45PM +, Stuart Dallas wrote:

 On 6 Feb 2012, at 05:58, Paul M Foster wrote:
 
  This is sort of obliquely related to PHP.
  
  I don't have a smart phone, but I need to know a couple of things:
 
 There are simulators available for most smartphones.
 
  1) Do smart phones use the same browsers as the desktop, or do they
  have their own stripped down versions of browsers?
 
 The trend is certainly moving towards full desktop capability, but
 personally I still think that if you expect a significant amount of
 traffic from mobile devices then your site should adapt accordingly.
 
  2) When a browser broadcasts its header telling the server what kind
  of browser is involved, do they broadcast anything in the header to
  indicate that they're being run on a smart phone?
 
 Yes, but there's no standard at the moment so detection requires
 something similar to https://gist.github.com/1124666. That code is
 pretty old, and I can't remember where I got it, but at the time it
 worked really well.
 
  3) Bonus question: Is there a preferred method amongst coders to
  determine what type of environment is being browsed from, so as to
  serve up the proper type of page (desktop or smart phone version of
  a webpage)?
 
 Generally speaking you're better off with a design that automatically
 adapts to the viewport on which it's being displayed. While there's
 more than one reason for this, the overriding reason is that the same
 software (i.e. the same user agent) could be running on any size of
 device, from watch to huge flat panel screen on a wall.
 
 I think the world needs to move on from is it a mobile device or not
 to accepting the reality which is that the browser / OS is irrelevant,
 and that the way your site renders should be purely based upon the
 size of the display. Responsive designs such as that described in the
 A List Apart article Mari posted are fantastic tools for achieving
 this goal.
 

I'm inclined to agree.

In fact, my daughter, who owns an iPhone, hates the mobile-only webpages
and will normally opt to see the full (desktop) website, even on her
iPhone. She'd rather gesture around the original website than see a
vastly simplified version with everything vertically stacked, as it
often is on strictly mobile sites.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Headers on smart phone browsers

2012-02-06 Thread Donovan Brooke

Paul M Foster wrote:
[snip]

How about this: those of you with iPhones, Androids and the like, point
your phones at a page which reports $_SERVER['HTTP_USER_AGENT'] (like a
page which runs the phpinfo() function), and post what you get back from
that exercise and what device made the query. I'd like to see if there
is anything significant which indicates handheld platforms.

Paul



Logical, but I can save you that step :-) as I've been there done that..

Here is a PHP script (uses $_SESSION) for mobile users that I have found 
to work fairly well. I'm absolutely sure that it contains false 
positives, and potentially other minor bugs.. as it's just hard to keep 
up with the ever changing UA's... but it's a start.


If it gets munged from email returns, I can zip it up.

Donovan



*INCLUDE IN HEAD
--start
?php
// ** Make sure to replace URL with your mobile URL below **

// Head
include('device_detect.php');//

session_start();
$is_mobile = mobile_device_detect();

if ($is_mobile) {   
header(Location: URL);
die();
}
?
--end



SAVE TO A FILE CALLED 'device_detect.php' 
--start
?php
// device_detect.php


function mobile_device_detect(){



  //check if force pc is requested

  $forcepc = isset($_REQUEST['forcepc']) ? $_REQUEST['forcepc']: 'false';

  if ($forcepc == 'true') {

  $_SESSION['forcepc'] = 'true';

  return false;

  } else if (isset($_SESSION['forcepc'])) {

  $forcepc = $_SESSION['forcepc'];

  if ($forcepc == 'true') {

   return false;

  }

  } else {

  $_SESSION['forcepc'] = 'false';

  }



  if (isset($_SESSION['mobiledevicedetect'])) { 

  return $_SESSION['mobiledevicedetect'];

  }



  //check if a profile header is indicated

  //this is a very good indication it is a mobile device

  if (isset($_SERVER['HTTP_X_WAP_PROFILE']) || 
isset($_SERVER['HTTP_PROFILE'])) {


  $_SESSION['mobiledevicedetect'] = true;

  return true;

  }



  $user_agent = $_SERVER['HTTP_USER_AGENT']; // get the user agent 
value - this should be cleaned to ensure no nefarious input gets executed


  $accept = $_SERVER['HTTP_ACCEPT']; // get the accept header value



  switch(true){ // using a switch against the following statements 
which could return true is more efficient than the previous method of 
using if statements




	case (eregi('ipod',$user_agent)||eregi('iphone',$user_agent)); // we 
find the words iphone or ipod in the user agent			


$_SESSION['mobiledevicedetect'] = true;

   return true;

   break;



	case 
(preg_match('/(nokia|sonyericsson|samsung|up.browser|up.link)/i',$user_agent)); 
// we find palm os in the user agent - the i at the end makes it case 
insensitive


   $_SESSION['mobiledevicedetect'] = true;

   return true;

   break;



case (eregi('android',$user_agent));  // we find android in the user 
agent

   $_SESSION['mobiledevicedetect'] = true;

   return true;

   break;



	case (eregi('opera mini',$user_agent)); // we find opera mini in the 
user agent


  $_SESSION['mobiledevicedetect'] = true;

  return true;

break;



	case (eregi('blackberry',$user_agent)); // we find blackberry in the 
user agent


  $_SESSION['mobiledevicedetect'] = true;

  return true;

break;



	case (preg_match('/(palm 
os|palm|hiptop|avantgo|plucker|xiino|blazer|elaine|treo)/i',$user_agent)); 
// we find palm os in the user agent - the i at the end makes it case 
insensitive


  $_SESSION['mobiledevicedetect'] = true;

  return true;

break;



	case (preg_match('/(windows ce; ppc;|windows ce; smartphone;|windows 
ce; iemobile)/i',$user_agent)); // we find windows mobile in the user 
agent - the i at the end makes it case insensitive


$_SESSION['mobiledevicedetect'] = true;

   return true;

break;



	case 
((strpos($accept,'text/vnd.wap.wml')0)||(strpos($accept,'application/vnd.wap.xhtml+xml')0)); 
// is the device showing signs of support for text/vnd.wap.wml or 
application/vnd.wap.xhtml+xml


   $_SESSION['mobiledevicedetect'] = true;

  return true;

break;



	case 

Re: [PHP] Headers on smart phone browsers

2012-02-06 Thread Donovan Brooke

Mari Masuda wrote:
[snip]

For a concrete example of responsive design in action, point your browser to 
http://www.sasquatchfestival.com/ and then slowly make the window 
wider/skinnier to see how the design adapts to different viewport sizes.



Very nice... makes for an easy display to a wide range of circumstances 
I think.. especially image resizing (in the blog example), which looks 
pretty smooth. But, in both the examples, it appears it can produce a 
choppy user experience when resizing the window as well...


I suppose that resizing could be viewed as one of those 80/20 percent 
rule things.. meaning, window resizing is probably not a prevalent 
action for a user and it could be argued that one shouldn't code a site 
worrying too much about dynamic window resizing... but then there is a 
form of resizing, which is turning your iPAD to landscape view, etc..


I suppose one could probably still do some UA detection and serve up 
content based on the type of UA (ie. mobile, IE, game-based) and at 
that point, still incorporate responsive web design, but to that 
more-limited-category of UA's.


Donovan





--
D Brooke

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Headers on smart phone browsers

2012-02-05 Thread Paul M Foster
This is sort of obliquely related to PHP.

I don't have a smart phone, but I need to know a couple of things:

1) Do smart phones use the same browsers as the desktop, or do they have
their own stripped down versions of browsers?

2) When a browser broadcasts its header telling the server what kind of
browser is involved, do they broadcast anything in the header to
indicate that they're being run on a smart phone?

3) Bonus question: Is there a preferred method amongst coders to
determine what type of environment is being browsed from, so as to serve
up the proper type of page (desktop or smart phone version of a
webpage)?

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Headers on smart phone browsers

2012-02-05 Thread Mari Masuda

On Feb 5, 2012, at 9:58 PM, Paul M Foster wrote:

[snip]

 3) Bonus question: Is there a preferred method amongst coders to
 determine what type of environment is being browsed from, so as to serve
 up the proper type of page (desktop or smart phone version of a
 webpage)?

[snip]

You should read up on responsive web design.  
http://www.alistapart.com/articles/responsive-web-design/ should get you 
started.  HTH!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php