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
2010-06-15 18:23:58
Nice one. Using **preg_match** for detecting Chrome would surely be an overhead.
Ain
2010-06-15 18:31:17