PHP: Detecting Google Chrome Browser
Posted on October 6, 2008, Filled under PHP,
Bookmark it
This is a short snippet useful to detect if the visitor uses Google Chrome Browser.
<?php
function is_chrome()
{
return(eregi("chrome", $_SERVER['HTTP_USER_AGENT']));
}
if(is_chrome())
{
// code for Chrome Browser here
echo 'You are using Google Chrome Browser.';
}
?>Do you wish to receive the latest updates as soon as they are posted? Get our RSS Feed or Subscribe to the Newsletter!
- October 6, 2008
- article by Gabriel C.
- 7 comments
Related Posts
Create, Customize and Send Newsletters: MeeNewsat August 3, 2009 with 1 comment
Integrate Your Buzz Stream Into Your Webpage: Google Buzz Widgetat February 16, 2010 with 1 comment
Insert Google AdSense Ads between your WordPress Blog Postsat July 13, 2009 with 21 comments

7 Replies to "PHP: Detecting Google Chrome Browser"
December 8, 2008 at 9:25 PM
[...] Probado en BitRepository [...]
June 6, 2009 at 9:28 PM
I dont fully understand the need for this?
July 12, 2009 at 3:13 AM
This code is great if you wish to display one set of output for Chrome, and another for (say) Firefox or Internet Explorer.
Thanks for providing this code… it really saved me today!
July 12, 2009 at 1:31 PM
@Eric Wood,
Thanks Eric, now i understand.
October 16, 2009 at 4:37 AM
[...] [...]
January 26, 2010 at 3:43 AM
Thx! This was just what i needed, and very simple to.
I use it because chrome of some reason wants a differen charset, than IE, and FF in some cases. (Too display special characters, when using AJAX, PHP, HTML, and CSS).
Thx alot!
July 5, 2010 at 10:15 PM
May be handy but strstr is significantly faster and more efficient than using eregi.
You should never use regular expression functions unless you’re using regular expressions.
Also this eregi is depreciated as of PHP 5.3.0 (php.net).