views:

51

answers:

1

I'm interested to know whether the user-agent is "Chrome" at the server end using PHP. Is there a reliable regular expression for parsing out the user-agent string from the request header?

+2  A: 

Just check $_SERVER['HTTP_USER_AGENT'] for the string 'Chrome'.

if (strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') !== false)
{
    // User agent is Google Chrome
}
BoltClock
Nice one. Using **preg_match** for detecting Chrome would surely be an overhead.
Ain