Detect Ipad, Iphone and Desktop using PHP


if(strstr($_SERVER['HTTP_USER_AGENT'],'iPad')){

     echo "Opened in IPad";

}else if(strstr($_SERVER['HTTP_USER_AGENT'],'iPod')){

     echo "Opened in IPhone";

}else{

     echo "Opened in Desktop";

}

Here comes the clear account of the code:

['HTTP_USER_AGENT']
This is the key in the server variable used in the code,serves the purpose of tracing out the gadget user has been utilizing.
It can be accessed from the server variable $_SERVER.
The code further follows up checking the gadget by simple If-Else loops and display the appropriate content.

Tags: , ,

Hi, Stranger! Leave Your Comment...

Name (required)
Email (required)
Website