Php checks whether the website is accessed by android, ios, or wp. Php judges whether it is android, ios, or wp to visit the website. The following section provides an example of php to determine whether it is android, ios, or wp to visit the website, it is very practical. I hope my friends can use php to determine whether to visit the website for android, ios, or wp.
Next, let's organize a php website access example to determine whether it is android, ios, or wp. it is very practical and helpful to all of you.
In php, you can use $ _ SERVER ['http _ USER_AGENT '] to distinguish between android, ios, and wp Requests. you can use the following code to implement this function:
$ UserAgent = $ _ SERVER ['http _ USER_AGENT '];
If (preg_match ("/(iPod | iPad | iPhone)/", $ userAgent ))
{
Echo 'iOS '; // ios client
}
Elseif (preg_match ("/WP/", $ userAgent ))
{
Echo 'WP '; // WinPhone client
}
Elseif (preg_match ("/android/I", $ userAgent )){
Echo 'Android'; // android client
}
Of course, I can add a js code in the webpage header to achieve the same effect.
In this way, as long as the mobile phone accesses the website, it will automatically go to the mobile phone version website.
In the following article, I will organize a php website access example for you to determine whether it is android, ios, or wp. it is very practical and I hope to give it to your friends...