Detect mobile web browsers with PHP

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.
}

Detect mobile browser with javascript

Detect mobile web browsers with Javascript.

HTML5 is making the web platform more powerful in a number of different areas. All the Smaprt phones come up with this HTML5 and CSS3 browsers . It is the easy medium to reach the mobile users as HTMl5 has almost all features that mobile native apps have. Now a day all the web site owners want to be their websites need to compatible with these smartphones.

unfortunatley these mobile browsers doesn’t have all the features as desktop browsers such as large screens,mouse and other hardware specifications. Most of the times we get a situation where our web applications must be optimized differently from the mobile and desktop. For this we need to detect the user is viewing our website from the desktop browser or mobile browser.

Here is a small Javscript snippet that usefull to detect almost modern mobile devices based on their mobile OS( operating systems).

if(navigator.userAgent.match(/Android|webOS|iPhone|iPod|BlackBerry|iPad/i)){
alert("Yea, you are on mobile browser");
}else {
alert("Yea, you are on desktop browser");
}

Types of mobile devices

Types mobile phones

A mobile device (also known as a handheld device, handheld computer ) is a small, hand-held computing device, typically having a display screen with touch input and/or a miniature keyboard.

The main category of mobile devices include the following devices

  • Personal Digital Assistant (PDA)
  • Smartphones
  • Tablet PC

Personal Digital Assistant (PDA) is

handheld devices that combine elements of computing, telephone/fax, Internet and networking in a single device. Examples: Revo, Hewlett-Packard Jornado, Compaq iPaq, Toshiba Pocket PC,Palm Pilot

Smartphone

combine both mobile phone and handheld computers into a single device. Smartphones allow users to store information (e.g., e-mail), install programs, along with using a mobile phone in one device.Examples: Palm Treo, Blackberry, Nokia T-Mobile , Torq, Motorola Q, I-mate,

Tablet PC

Tablet PCs are a type of notebook computer that has an LCD screen on which you can write using a stylus. The handwriting is digitized and can be converted to standard text through handwriting recognition, or it can remain as handwritten text. Examples : Samsung Q1, Toshiba Portege, IBM Thinkpad

 

list of mobile phones OS

A quick list of mobile operating systems

A mobile operating system (Mobile OS) is the software operating system that operates on mobile devices such as mobile phones, smartphones, PDAs, and hand-held computers. Mobile OS is a mobile version of an operating system found on computers.

Here is the list of most common operating systems (OS) found on smartphones and it’s manufacturers.

  • Symbian OS – Nokia Cell Phone operating system
  • Android OS – Google’s free, open-source cellphone operating system
  • iPhone OS (iOS ) – Apple’s mobile operating system
  • BlackBerry OS – Proprietary mobile operating system, developed by Research In Motion for its BlackBerry
  • Windows Phone 7 ( Windows Mobile ) – Mobile operating system developed by Microsoft
  • Palm OS (Garnet OS)- mobile operating system initially developed by Palm
  • Palm webOS – Mobile operating system from HP/Palm
  • Bada – Mobile operating system developed by Samsung Electronics
  • Maemo OS – from Nokia (open source, GPL)
  • MeeGo OS – from Nokia and Intel (open source, GPL)