Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
PHP Detect Device is an PC or Mobile
Old 06-04-2011, 08:03 PM PHP Detect Device is an PC or Mobile
expertspk's Avatar
Junior Talker

Posts: 2
Trades: 0
Hi,

Welcome all members on TycoonTaalk, This is my first thread on this forum, hope you will like it and get benefit of this script.

I am sharing a function for detect that Device is a PC (Personal Computer) or A mobile .

PHP Code:
<?php

function is_mobile() {

    
// Get Browser

    
$user_agent $_SERVER['HTTP_USER_AGENT'];




    
$mobile_agents = Array(


        
"240x320",
        
"acer",
        
"acoon",
        
"acs-",
        
"abacho",
        
"ahong",
        
"airness",
        
"alcatel",
        
"amoi",    
        
"android",
        
"anywhereyougo.com",
        
"applewebkit/525",
        
"applewebkit/532",
        
"asus",
        
"audio",
        
"au-mic",
        
"avantogo",
        
"becker",
        
"benq",
        
"bilbo",
        
"bird",
        
"blackberry",
        
"blazer",
        
"bleu",
        
"cdm-",
        
"compal",
        
"coolpad",
        
"danger",
        
"dbtel",
        
"dopod",
        
"elaine",
        
"eric",
        
"etouch",
        
"fly " ,
        
"fly_",
        
"fly-",
        
"go.web",
        
"goodaccess",
        
"gradiente",
        
"grundig",
        
"haier",
        
"hedy",
        
"hitachi",
        
"htc",
        
"huawei",
        
"hutchison",
        
"inno",
        
"ipad",
        
"ipaq",
        
"ipod",
        
"jbrowser",
        
"kddi",
        
"kgt",
        
"kwc",
        
"lenovo",
        
"lg ",
        
"lg2",
        
"lg3",
        
"lg4",
        
"lg5",
        
"lg7",
        
"lg8",
        
"lg9",
        
"lg-",
        
"lge-",
        
"lge9",
        
"longcos",
        
"maemo",
        
"mercator",
        
"meridian",
        
"micromax",
        
"midp",
        
"mini",
        
"mitsu",
        
"mmm",
        
"mmp",
        
"mobi",
        
"mot-",
        
"moto",
        
"nec-",
        
"netfront",
        
"newgen",
        
"nexian",
        
"nf-browser",
        
"nintendo",
        
"nitro",
        
"nokia",
        
"nook",
        
"novarra",
        
"obigo",
        
"palm",
        
"panasonic",
        
"pantech",
        
"philips",
        
"phone",
        
"pg-",
        
"playstation",
        
"pocket",
        
"pt-",
        
"qc-",
        
"qtek",
        
"rover",
        
"sagem",
        
"sama",
        
"samu",
        
"sanyo",
        
"samsung",
        
"sch-",
        
"scooter",
        
"sec-",
        
"sendo",
        
"sgh-",
        
"sharp",
        
"siemens",
        
"sie-",
        
"softbank",
        
"sony",
        
"spice",
        
"sprint",
        
"spv",
        
"symbian",
        
"tablet",
        
"talkabout",
        
"tcl-",
        
"teleca",
        
"telit",
        
"tianyu",
        
"tim-",
        
"toshiba",
        
"tsm",
        
"up.browser",
        
"utec",
        
"utstar",
        
"verykool",
        
"virgin",
        
"vk-",
        
"voda",
        
"voxtel",
        
"vx",
        
"wap",
        
"wellco",
        
"wig browser",
        
"wii",
        
"windows ce",
        
"wireless",
        
"xda",
        
"xde",
        
"zte"
    
);

    
// Pre-set $is_mobile to false.

    
$is_mobile false;

    
// Cycle through the list in $mobile_agents to see if any of them
    // appear in $user_agent.

    
foreach ($mobile_agents as $device) {

        
// Check each element in $mobile_agents to see if it appears in
        // $user_agent.  If it does, set $is_mobile to true.

        
if (stristr($user_agent$device)) {

            
$is_mobile true;

            
// break out of the foreach, we don't need to test
            // any more once we get a true value.

            
break;
        }
    }

    return 
$is_mobile;
}



?>

If function will detect a mobile it will return 1 otherwise it will return 0 or empty value.


- Good Bye
ALLAH HAFIZ
expertspk is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to PHP Detect Device is an PC or Mobile
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.08111 seconds with 12 queries