需要帮助使用PHP来检测iOS版本以提供正确的图标

Given the fact that iOS 7 is changing the look of icons, I'm trying to figure out a way of detecting which iOS version visitors to our site are using, and thus serve up the appropriate icon for the device... particularly for when pinning to home screen. What I have at present is :

function add_theme_favicon() {
echo '<link rel="shortcut icon" href="/favicon.ico" >';
if(strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone OS 7_\d') !== false) { 
echo  '<link rel="apple-touch-icon-precomposed" href="' . TF_FAV . '/new_favicon_256x256.png" >';
}
else {
    echo '<link rel="apple-touch-icon-precomposed" href="' . TF_FAV . '/favicon_256x256.png" >';
    }
}
add_action('wp_head', 'add_theme_favicon');

Unfortunately something isn't right as the the same image is getting served to all versions of iOS. Can someone point me in the right direction on this one?

Function strpos doesn't use regular expressions. You need to find 'iPhone OS 7_' instead of 'iPhone OS 7_\d'. As you can test HTTP_USER_AGENT doesn't contain \d.