Sol Sol - 8 months ago 51
PHP Question

PHP how to detect chrome on IOS, Android, and Windows?

eregi is an older code and works when I load chrome for chrome specific functions. I have seen Java tutorials on detection for iOS, Android, and windows, but for PHP it seems limited.

seemed to give me issues on how this was used. How would you detect it on all 3 so you get the correct browser?

This is what I currently use:

function is_chrome()
return(eregi("chrome", $_SERVER['HTTP_USER_AGENT']));
//return(preg_match(“/applewebkit/i”, $_SERVER[‘HTTP_USER_AGENT’]));

// code for Chrome Browser here

echo $chrome = 'You are using Google Chrome Browser.';

} else{
echo $chrome = 'hide';



You could use some 3rd party library to detect browsers, e.g. Browser.php

Typical Usage:

$browser = new Browser();
if( $browser->getBrowser() == Browser::BROWSER_CHROME && $browser->getPlatform() == Browser::PLATFORM_WINDOWS ) {
    echo 'Chrome on Windows';