Wednesday 14 August 2013

How to check if the request came from mobile or computer using php



 Include Mobile_Detect.php file  Download from Here
<?php
require_once ('Mobile_Detect.php');
$detect = new Mobile_Detect;
$deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer');
$scriptVersion = $detect->getScriptVersion();
?>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0,    minimum-scale=1.0, user-scalable=no">
</head>
<body>
    <p>This is a <b><?php echo $deviceType; ?></b></p>
</body>
</html>

No comments:

Post a Comment