본문으로 바로가기

[PHP] 접속 브라우저 알아내기

category Helloworld!/PHP 2013. 8. 9. 14:17
function getBrowser() {
    $broswerList = array('MSIE', 'Chrome', 'Firefox', 'iPhone', 'iPad', 'Android', 'PPC', 'Safari', 'none');
    $browserName = 'none';

    foreach ($broswerList as $userBrowser){
        if($userBrowser === 'none') break;
        if(strpos($_SERVER['HTTP_USER_AGENT'], $userBrowser)) {
            $browserName = $userBrowser;
            break;
        }
    }
    return $browserName;
}
반환 값 = MSIE, Chrome, Firefox, iPhone, iPad, Android, PPC, Safari, none



댓글을 달아 주세요

  1. Favicon of https://88240.tistory.com BlogIcon shaking shaking 신고">2013.08.09 14:20 신고

    http://liesm.tistory.com/entry/PHPJavascript-%EC%A0%91%EC%86%8D-%EB%B8%8C%EB%9D%BC%EC%9A%B0%EC%A0%80-%EA%B5%AC%ED%95%98%EA%B8%B0

  2. Favicon of https://88240.tistory.com BlogIcon shaking shaking 신고">2015.06.05 18:22 신고

    http://php.net/manual/kr/tutorial.useful.php