?
Solved

Detect Goolge Chrome browser not working

Posted on 2010-09-16
3
Medium Priority
?
356 Views
Last Modified: 2012-05-10
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
0
Comment
Question by:peps03
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 2

Expert Comment

by:kostantinos1995
ID: 33694204
Check this out:

if ( eregi("chrome", $_SERVER['HTTP_USER_AGENT']) ) {
// Google chrome
} else {
// Not Google chrome
}
0
 
LVL 14

Accepted Solution

by:
Phil Phillips earned 2000 total points
ID: 33695296
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
 

Author Closing Comment

by:peps03
ID: 33695588
Thanks Decorum!!

Its finally working the way i want it to!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question