나는이 PHP 스크립트를 작동 시키려고 노력했지만, 제대로 작동하지 않는 것 같습니다. : \PHP에서 정의되지 않은 변수, 내가 뭘 잘못하고 있니?
<?php function getBrowser() {
$u_agent = $_SERVER['HTTP_USER_AGENT'];
$ub = '';
if(preg_match('/MSIE/i',$u_agent)) {
$ub = "Internet Explorer";
}
elseif(preg_match('/Firefox/i',$u_agent)) {
$ub = "Mozilla Firefox";
}
elseif(preg_match('/Safari/i',$u_agent)) {
$ub = "Apple Safari";
}
elseif(preg_match('/Chrome/i',$u_agent)) {
$ub = "Google Chrome";
}
elseif(preg_match('/Opera/i',$u_agent)) {
$ub = "Opera";
}
elseif(preg_match('/Netscape/i',$u_agent)) {
$ub = "Netscape";
}
return $ub;
}
echo $ub;
?>
난 그냥 PHP가 제대로 브라우저를 감지하기 위해 노력하고 있어요,하지만 난 항상 "정의되지 않은 변수 : UB"얻을 수있는 "에코 $의 UB;"
이번에는 무엇이 잘못 되었습니까?
오류 또는 경고가 표시됩니다. –