Skip to content Skip to sidebar Skip to footer

PHP Detect Browser

Reading Time: < 1 minute

How can I detect browser using php.You can use php server variable $_SERVER[‘HTTP_USER_AGENT’] for this.It will return about the user’s operating system, as well as their browser.It contents of the User-Agent header from the current request.
So simply you can echo this for more understand.

Mozilla/5.0 (Windows NT 6.1; rv:14.0) Gecko/20100101 Firefox/14.0.1


    if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE){
    	echo 'Internet explorer';
    else if(strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== FALSE){
    	echo 'Mozilla Firefox';
    else if(strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') !== FALSE) {
    	echo 'Google Chrome';
    else if(strpos($_SERVER['HTTP_USER_AGENT'], 'Safari') !== FALSE) {
    	echo 'Safari';
    else {
    	echo 'Something else';

You can check iPad like this.

private function ipad_request() {
    return isset($_SERVER['HTTP_USER_AGENT']) && strstr($_SERVER['HTTP_USER_AGENT'], 'iPad');