Solved

Detect Goolge Chrome browser not working

Posted on 2010-09-16
3
343 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
3 Comments
 
LVL 2

Expert Comment

by:kostantinos1995
Comment Utility
Check this out:

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

Accepted Solution

by:
Phil Phillips earned 500 total points
Comment Utility
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
Comment Utility
Thanks Decorum!!

Its finally working the way i want it to!
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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 is …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

771 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now