Detect mobile web browsers with PHP.
We have learned about detecting mobile browsers with Javascript and do need full implementation for mobile devices separately, however we need to detect these mobile browsers on server side and implementing the mobile UI without any redirecting the user.
for example :
if user browses our website through the desktop browser we display web interface .
if user browse our website through mobile browser we load the mobile interface .
Here is a small PHP snippet that useful to detect almost modern mobile devices based on their mobile OS( operating systems).
$user_agent = $_SERVER['HTTP_USER_AGENT']; // get the user agent value if(preg_match('/Android|webOS|iPhone|iPod|BlackBerry|iPad/i',$user_agent)){ //load mobile interface }else { //load web interface. } |

