Reputation: 26075
I want to serve mobile content for text browsers or browsers without CSS support. Is this possible using PHP?
Upvotes: 1
Views: 326
Reputation: 145482
There aren't that many text based browsers. (I'm using w3m, and then there's only lynx, links, elinks; the others are mostly historic.)
But as a more deterministic alternative (however: cookie dependency!) you could build a trap:
<link rel="stylesheet trap" ref="ping-css.php">
Which simply updates a session or cookie value to check later:
<?php setcookie("css_supported", "yay"); ?> #faux-css { }
A note of concern would be that screenreaders (which are quasi text browsers too) also can consume CSS declarations. And some variants of elinks
do too. But then again, you could built a more elaborate trap using @media tty
or check via @media screen
if it's a graphical browser.
Upvotes: 0
Reputation: 782
There's the native function get_browser, that returns a bunch of information based on the $_SERVER['HTTP_USER_AGENT'] variable.
http://php.net/manual/en/function.get-browser.php
Upvotes: 1
Reputation: 10104
You can look at the http User-Agent
header via the php global $_SERVER['HTTP_USER_AGENT']
. Of course you'll need to know what User-Agent
s to look for... You could start by searching here: http://www.user-agents.org/
Upvotes: 0