Detect iPad in php?

How can I use another page to view on iPad?

+5
source share
4 answers
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";
}

See http://developer.apple.com/safari/library/technotes/tn2010/tn2262.html

Also, if you are not worried about an exact match, you might consider something like:

if(stristr($_SERVER['HTTP_USER_AGENT'], 'Mozilla/5.0(iPad;')) {
    // probably an iPad
}
+9
source

You can sniff the iPad user-agentheader using $_SERVER['HTTP_USER_AGENT'], but ideally, if you can recognize things that you want to be different from the iPad compared to any other device, more reliable and flexible than the agent who sniffs.

+6
source

, , , , .

if (strstr($_SERVER['HTTP_USER_AGENT'], 'iPad')) {
   echo "You are on an iPad";
}
+3

:

Mozilla/5.0 (iPad, U, CPU OS 3_2, Mac OS X, en-us) AppleWebKit/531.21.10 (KHTML, , Gecko) /4.0.4 Mobile/7B367 Safari/531.21.10

, "iPad".

+1

All Articles