html - Detect ie10, < ie10 and other browsers in php -


i have code detect if user using ie browser, detect if ie 10 or version below ie 10

<?php     $u_agent = $_server['http_user_agent'];     if(preg_match('/msie/i',$u_agent)){        //do        //how know ie 10        // how know browser version less ie 10?     }else{        //hope users use other browser ie      }       ?> 

so correct?

 <?php         $u_agent = $_server['http_user_agent'];         //ie         if(preg_match('/msie/i',$u_agent)){             //ie 10            if(preg_match('/msie 10/i', $_server['http_user_agent'])) {                      //  ie10.            // < ie 10            }else{                      //  < ie10.            }           }else{            //other browsers             //hope users use other browser ie          }           ?> 

this might you:

<?php  //echo $_server['http_user_agent'];   if(preg_match('/(?i)msie [10]/',$_server['http_user_agent'])) {     // if ie = 10    echo "version ie 10"; //rest of code } else {     // if not 10      echo "version not 10"; //rest of code }  ?> 

demo here>>

edit: break 3 cases:

<?php  //echo $_server['http_user_agent'];   if(preg_match('/(?i)msie [1-9]/',$_server['http_user_agent'])) {     // if ie <= 10    echo "version less 10"; //rest of code } else  if(preg_match('/(?i)msie [10]/',$_server['http_user_agent'])) {     // if ie = 10    echo "version ie 10"; //rest of code } else {     // if not 10      echo " other browser"; //rest of code  }  ?> 

demo here>>


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -