Solved

Detect Goolge Chrome browser not working

Posted on 2010-09-16
3
345 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
ID: 33694204
Check this out:

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

Accepted Solution

by:
Phil Phillips earned 500 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

776 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