Return to Snippet

Revision: 15358
at July 1, 2009 16:04 by Thresh


Initial Code
<?

function is_iPhone($agent='') {
    if(empty($agent)) $agent = $_SERVER['HTTP_USER_AGENT'];
    if(!empty($agent) and preg_match("~Mozilla/[^ ]+ \((iPhone|iPod); U; CPU [^;]+ Mac OS X; [^)]+\) AppleWebKit/[^ ]+ \(KHTML, like Gecko\) Version/[^ ]+ Mobile/[^ ]+ Safari/[^ ]+~",$agent,$match)) {
        return "YES";
    } elseif(stristr($agent,'iphone') or stristr($agent,'ipod')){
        return "MAYBE";
    } else {
        return "NO";
    }
}

echo is_iPhone();
?>

Initial URL
http://www.laydo.net/2009/07/01/iphone-tarayici-tespiti-safari/?preview=true&preview_id=281&preview_nonce=368872e6b4

Initial Description

                                

Initial Title
detect iphone browser

Initial Tags
php, browser, iphone

Initial Language
PHP