How to detect mobile device such as Ipad,iphone,table and windows phone with PHP

comments

The Internet took off quicker than anyone would have predicted, growing like crazy. Now, for the past few years, mobile growth has exploded onto the scene. The growth of mobile Internet usage is also far out pacing that of general Internet usage growth.

These days it is hard to find someone who doesn’t own a mobile device, or multiple, connected to the Internet.

With the growth in mobile Internet usage comes the question of how to build websites suitable for all users. The industry response to this question has become responsive web design, also known as RWD.

here is a simile code that you can use to detect them via PHP!

$is_mobile = preg_match( '/' . apply_filters( 'et_mobile_regex','Android|android.+mobile|avantgo|bada/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)/|plucker|pocket|psp|symbian|treo|up.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino|htc |ipad' ) . '/i', $_SERVER['HTTP_USER_AGENT'] ) ? true : false;
        if($is_mobile){
            echo "Mobile";
        }else{
            echo "Desktop"; 
       }

this is a  regular expression and you can change it to yours !

Android|android.+mobile|avantgo|bada/|blackberry|blazer|compal|elaine|fennec

|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)/|plucker|pocket|psp|symbian|treo|up.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino|htc |ipad’

have fun 😉

About the Author: mohammad

Leave a Reply

Your email address will not be published. Required fields are marked *