isClientTablet() ::
For the purposes of supporting front-end and back-end functional use case requirements which walk lock-step with the need to accurately determine client device type from the server-side, C
RNRSTN Suite :: v2.0.0 incorporates into itself an active and developer supported open source PHP project,
Mobile Detect, in order to leverage the deep specialization of that project in the areas of mobile device and tablet computer detection over HTTP/S. isClientTablet() will enable the running application to cater to the experience of an end-user request coming from the tablet (and also mobile) device channel.
Note ::
This functionality stands on top of the
Mobile Detect project which has been incorporated into C
RNRSTN Suite v2.0.0.
Mobile Detect is a lightweight PHP class for detecting mobile devices (including tablets). It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.
Mobile Detect is sponsored by it's developers and community, and they send thanks to the JetBrains team for providing
PHPStorm and
DataGrip licenses for said project.
Technical specifications ::
- Currently tested on an Ubuntu Server 18.04 running PHP 7.0.22/MySQLi 5.0.12 and CentOS 7 Linux (a 100% compatible rebuild of the Red Hat Enterprise Linux) running PHP 5.6.32/MySQLi 5.5.58.
- It is recommended that you upgrade to the latest official release of PHP to take advantage of gains in security and processing efficiency together with the latest features and functionality.
Invoking class ::
crnrstn_user
Method definition ::
isClientTablet($mobileIsTablet=false)
Method parameter definitions ::
$mobileIsTablet (Optional)
Boolean value where TRUE indicates that mobile devices should be treated as tablet computer and where FALSE only allows identified-as-tablet user-agent and HTTP headers to qualify as tablet.
Returned value ::
Returns a string 'isTablet' on successful tablet match. 'isMobile' will be returned, however, if $mobileIsTablet is passed in as TRUE and the User-Agent and HTTP headers indicate that the client is a mobile device. FALSE is returned for non-successful matches.
Example 1 ::
Retrieve a multi data-type response as indication of the existence of conditions which...to a high degree of probability...confirm (or deny) that this is a request originating from a mobile device or tablet computer.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
/*
// J5
// Code is Poetry */
require('_crnrstn.root.inc.php');
include_once($CRNRSTN_ROOT . '/_crnrstn.config.inc.php');
//
// PASSING TRUE ALLOWS MOBILE DEVICES TO BE DETECTED AS TABLET.
$iAmTablet = $oCRNRSTN_USR->isClientTablet();
if($iAmTablet){
//
// TABLET DEVICE EXPERIENCE
echo 'I am a tablet!';
}else{
//
// DESKTOP (OR EVEN MOBILE, FOR THIS EXAMPLE) EXPERIENCE
echo 'I am not a tablet!';
}
?>
Example 1 Output ::