[PHP] 透過 $_SERVER['HTTP_USER_AGENT'] 來判斷使用者是否使用IE
資料來源:PHP官網
<?php
function using_ie(){
$u_agent = $_SERVER['HTTP_USER_AGENT'];
$ub = False;
if(preg_match('/MSIE/i',$u_agent))
{
$ub = True;
}
return $ub;
}
function ie_box() {
if (using_ie()) {
?>
<div class="iebox">
This page is not designed for Intenet Explorer. If you want to see this webpage as intended, please use a standards compliant browser, such as <a href="http://www.google.com/chrome">Google Chrome</a>.
</div>
<?php
return;
}
}
?>
<?php
function using_ie(){
$u_agent = $_SERVER['HTTP_USER_AGENT'];
$ub = False;
if(preg_match('/MSIE/i',$u_agent))
{
$ub = True;
}
return $ub;
}
function ie_box() {
if (using_ie()) {
?>
<div class="iebox">
This page is not designed for Intenet Explorer. If you want to see this webpage as intended, please use a standards compliant browser, such as <a href="http://www.google.com/chrome">Google Chrome</a>.
</div>
<?php
return;
}
}
?>