Elxis CMS Forum

Support => General => Topic started by: xmanhattan on September 22, 2012, 13:41:00

Title: browser detection
Post by: xmanhattan on September 22, 2012, 13:41:00
Hello all,

I have a small problem with jquery and opera.  I would like to know what is the php code to use to detect opera to add a small javascript routine.

Title: Re: browser detection
Post by: webgift on September 22, 2012, 15:03:23
You can simply use stripos (http://php.net/manual/en/function.stripos.php) function of php and global $_SERVER variable like this:

if (stripos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false) {
   echo 'You use Opera browser!';
}
Title: Re: browser detection
Post by: xmanhattan on September 22, 2012, 15:46:29
Ouch, I didn't even think of that.  I thought that there might be a special function.

Thanks
Title: Re: browser detection
Post by: webgift on September 22, 2012, 15:49:49
You are welcome, Peter!  ;)