A-AA+then

เห็นกันแต่ของ Javascript ของ PHP ก็มีให้ตรวจสอบได้ครับ

<?
function getBrowser()
{
 $useragent = $_SERVER['HTTP_USER_AGENT'];

 if(preg_match('|Netscape/([0-9\.]+)|',$useragent,$matched)) {
  $browser_version=$matched[1];
  $browser = 'Netscape';
 } elseif (preg_match('|MSIE ([0-9].[0-9]{1,2})|',$useragent,$matched)) {
  $browser_version=$matched[1];
  $browser = 'IE';
 } elseif (preg_match( '|Opera ([0-9].[0-9]{1,2})|',$useragent,$matched)) {
  $browser_version=$matched[1];
  $browser = 'Opera';
 } elseif(preg_match('|Firefox/([0-9\.]+)|',$useragent,$matched)) {
  $browser_version=$matched[1];
  $browser = 'Firefox';
 } elseif(preg_match('|Safari/([0-9\.]+)|',$useragent,$matched)) {
  $browser_version=$matched[1];
  $browser = 'Safari';
 } else {
  //ไม่รู้จัก
  $browser_version = 0;
  $browser= 'other';
 }
 return array( $browser , $browser_version );
};
?>

ตัวอย่าง

<?
 $browsers = getBrowser();
 print "browser: ".$browsers[0]." ".$browsers[1];
?>

PHP

Relate

^