Snippet. PHP. Find if Visitor's Browser is iPone

This one line PHP snippet allows you to fond out if the visitor is using iPhone to browse your website.

$is_browser_iphone = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone")?true:false;

Exmple:

if ($is_broser_iphone) {
    // Output icon for iPhone (must be 57x57 pixels)
    echo '';

    // Output meta for iPhone
    echo '';
    
    // Output stylesheet for iPhone
    echo '';
}

Updated on: 23 Nov 2024