if($_SERVER['HTTP_USER_AGENT'] == 'Mozilla/5.0(iPad; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10') {
echo "That is an iPad";
}
Run Code Online (Sandbox Code Playgroud)
请参阅https://developer.apple.com/library/content/technotes/tn2010/tn2262/_index.html
此外,如果您没有精确匹配,您可能会考虑以下内容:
if(stristr($_SERVER['HTTP_USER_AGENT'], 'Mozilla/5.0(iPad;')) {
// probably an iPad
}
Run Code Online (Sandbox Code Playgroud)
您可以嗅出了iPad的user-agent头通过$_SERVER['HTTP_USER_AGENT'],但理想的,如果你能拥有侦测你想在iPad上的不同与任何其他设备的事情,这是更强大,比代理嗅探灵活.