Detect Goolge Chrome browser not working

Hi,

I'm tring to detect the google chrome browser like this:

<?    if (strpos($_SERVER['HTTP_USER_AGENT'], 'chrome') !== FALSE)
        echo "you're chrome..";
    else
        echo "not using google chrome.....!";?>

But it doesn't work..

This does work:
<?    if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE)
        echo "you're ie..";
    else
        echo "no ie!";?>

What am i doing wrong? I would says its in the name "chrome" because the code is the same..

Thanks
peps03Asked:
Who is Participating?
 
Phil PhillipsConnect With a Mentor Director of DevOps & Quality AssuranceCommented:
You might want to do something like:

if ( strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'chrome') !== false ) {
  //Is Chrome
}
else {
  //NOT chrome
}

(The use of eregi is deprecated as of PHP 5.3)
0
 
kostantinos1995Commented:
Check this out:

if ( eregi("chrome", $_SERVER['HTTP_USER_AGENT']) ) {
// Google chrome
} else {
// Not Google chrome
}
0
 
peps03Author Commented:
Thanks Decorum!!

Its finally working the way i want it to!
0
All Courses

From novice to tech pro — start learning today.