smetterd
asked on
Advice on PHP browser detection, specifically Palm
The following seems to work well... I would like to get expert opinion on if it's a good way to do it...
//If principal is using a Palm, then set it for presentation changes, etc.
$string = $_SERVER['HTTP_USER_AGENT' ];
$substring = 'Palm';
$pos = 0;
$pos = strpos($string, $substring, $pos);
if ($pos ==''){
$isPalm="0";
}
else {
$isPalm="1";
}
-------------------------- ---------- ---------
//If principal is using a Palm, then set it for presentation changes, etc.
$string = $_SERVER['HTTP_USER_AGENT'
$substring = 'Palm';
$pos = 0;
$pos = strpos($string, $substring, $pos);
if ($pos ==''){
$isPalm="0";
}
else {
$isPalm="1";
}
--------------------------
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It's well deserved. What a USEFUL script!
Hi Ellandrd,
Thanks for this super-useful reply! I hope you're still around and wouldn't mind answering a couple of follow-up newbie questions:
1. If I am using a CMS, where would I put the code? The CMS (Concrete5) delivers everything from a database to the index.php page.
2. What do I need to do to actually have it do the re-direct? I think this code just has placeholders...
if($mobile_browser > 0)
{
// is a mobile browser
}
else
{
// is not a mobile browser
Thanks so much!
Andrey
Thanks for this super-useful reply! I hope you're still around and wouldn't mind answering a couple of follow-up newbie questions:
1. If I am using a CMS, where would I put the code? The CMS (Concrete5) delivers everything from a database to the index.php page.
2. What do I need to do to actually have it do the re-direct? I think this code just has placeholders...
if($mobile_browser > 0)
{
// is a mobile browser
}
else
{
// is not a mobile browser
Thanks so much!
Andrey
Ellandrd