Jump to content

Find device user is using


rkstevens

Recommended Posts

Is there a way in PHP to be able to detect the media type of the user?

I want to be able to detect if the user is using a handheld device (cell phone browser or smartphone) and do one of two things: have different code for handheld that uses less bandwidth; redirect to a different page.

 

Link to comment
https://forums.phpfreaks.com/topic/102345-find-device-user-is-using/
Share on other sites

Try by detecting the user agent:

 

<?php
$userangent = $_SERVER['HTTP_USER_AGENT'];
if(strstr($useragent, 'Blackberry')){ //where blackberry is the device
    echo 'You are on mobile';
} else{
    echo 'You are on pc';
}
?>

 

To check for several devices, make an array with all the devices. Hope this helps.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.