|
|
|
ตรวจสอบ browser อยากได้ code ที่ทำการตรวจสอบ browser ครับ |
|
|
|
|
|
|
|
Code (PHP)
<?php
<?php
$useragent = $_SERVER[‘HTTP_USER_AGENT’]);
if (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 not recognized!
$browser_version = 0;
$browser= ‘other’;
}
print “browser: $browser $browser_version”;
?>
?>
|
|
|
|
|
Date :
2009-08-07 14:03:26 |
By :
Sek-nakarin |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
โค้ดผิดอะคับ
|
|
|
|
|
Date :
2009-08-07 14:14:01 |
By :
ken |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
มีความแตกต่างกันของ ' และ " ครับ
Code (PHP)
<?php
$useragent = $_SERVER["HTTP_USER_AGENT"];
if (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 not recognized!
$browser_version = 0;
$browser= "other";
}
echo "browser $browser $browser_version";
?>
|
|
|
|
|
Date :
2009-08-07 14:56:30 |
By :
lozomac |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?php
<?php
//function getbrowser(){
$agent = $_SERVER['HTTP_USER_AGENT'];
if(eregi("Netcaptor", $agent)){ $browser = "Netcaptor";
} elseif(eregi("(opera) ([0-9]{1,2}.[0-9]{1,3}){0,1}", $agent, $ver) || eregi("(opera/)([0-9]{1,2}.[0-9]{1,3}){0,1}", $agent, $ver)){ $browser = "Opera $ver[2]";
} elseif(eregi("(konqueror)/([0-9]{1,2}.[0-9]{1,3})", $agent, $ver)){ $browser = "Konqueror $ver[2]";
} elseif(eregi("(lynx)/([0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2})", $agent, $ver)){ $browser = "Lynx $ver[2]";
} elseif(eregi("(msie) ([0-9]{1,2}.[0-9]{1,3})", $agent, $ver)){ $browser = "Internet Explorer $ver[2]";
} elseif(eregi("Links", $agent)){ $browser = "Lynx";
} elseif(eregi("(Firebird/)([0-9]{1,2}.[0-9]{1,3}){0,1}", $agent, $ver)){ $browser = "Firebird $ver[2]";
} elseif(eregi("(Firefox/)([0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2})", $agent, $ver)){ $browser = "FireFox $ver[2]";
} elseif(eregi("Mozilla/5",$agent)){$browser = "Netscape 5";
} elseif(eregi("Gecko", $agent)){ $browser = "Mozilla";
} elseif(eregi("Safari",$agent)){ $browser = "OS-X Safari";
} elseif(eregi("(netscape6)/(6.[0-9]{1,3})", $agent, $ver)){ $browser = "Netscape $ver[2]";
} elseif(eregi("(Mozilla)/([0-9]{1,2}.[0-9]{1,3})", $agent, $ver)){ $browser = "Netscape $ver[2]";
} elseif(eregi("Galeon", $agent)){ $browser = "Galeon";
} elseif(eregi("(lynx)/([0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2})", $agent, $ver) ){$browser = "Lynx $ver[2]";
} elseif(eregi("Avant Browser", $agent)){ $browser = "Avant";
} elseif(eregi("(omniweb/)([0-9]{1,2}.[0-9]{1,3})", $agent, $ver) ){$browser = "OmniWeb $ver[2]";
} elseif(eregi("ZyBorg|WebCrawler|Slurp|Googlebot|MuscatFerret|ia_archiver", $agent)){ $browser = "Web indexing robot";
} elseif(eregi("(webtv/)([0-9]{1,2}.[0-9]{1,3})", $agent, $ver) ){$browser = "WebTV $ver[2]";
} else {$browser = "Unknown";}
//return $browser."00";
echo $browser;
//}
?>
?>
|
|
|
|
|
Date :
2009-08-07 15:03:46 |
By :
Sek-nakarin |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ดูแล้วลำบากใจจัง
|
|
|
|
|
Date :
2011-06-01 23:57:30 |
By :
MM-SCript |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แจ้งเตือนใช้ javascript ก็พอมั้งครับ jquery browser รับรองง่ายยิ่งกว่าพลิกผ่ามืออีก
|
|
|
|
|
Date :
2011-06-02 00:04:48 |
By :
PlaKriM |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ทดสอบตรวจสอบกับ Chrome แล้วรายงานผลออกมาผิดเป็น Netscape ซะงั้น
ทำไงดีครับ ช่วยหน่อย
|
|
|
|
|
Date :
2011-12-29 11:43:09 |
By :
หนุ่ม |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|