Link to home
Start Free TrialLog in
Avatar of smetterd
smetterdFlag for United States of America

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";
   }
---------------------------------------------
ASKER CERTIFIED SOLUTION
Avatar of ellandrd
ellandrd
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks for the grade ;-)

Ellandrd
Avatar of smetterd

ASKER

It's well deserved. What a USEFUL script!
Avatar of andreyman3d2k
andreyman3d2k

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