get_browser - Gets the functionality that the browser has. This function browscap.ini attempts to detect the functionality of a user's browser by locating the browser information in the file.
Due to the amount of license, PHP does not provide browser function files, you can get browser function files from Browscap, you can download Php_browscap.ini files in http://browscap.org/.
After download, it needs to be set in PHP.ini (Win):
Browscap=d:\wamp\bin\php\php5. 5.12\browscap.ini
or (under Linux)
Browscap=/usr/local/php/lib/php/browscap.ini
You can now print out the Get_browser () in the PHP file
Var_dump (Get_browser ());
Output:
Object(StdClass) #1( the) { ["Browser_name_regex"]=>string(101)"~^mozilla/5\.0 \ (. *windows nt 10\.0.*\) applewebkit/.* \ (khtml, like gecko\) chrome/49\: *safari/.*$~" ["Browser_name_pattern"]=>string( -)"mozilla/5.0 (*windows NT 10.0*) applewebkit/* (khtml, like Gecko) chrome/49.*safari/*" ["Parent"]=>string( One)"Chrome 49.0" ["Platform"]=>string(5)"Win10" ["Comment"]=>string( One)"Chrome 49.0" ["Browser"]=>string(6)"Chrome" ["Browser_maker"]=>string(Ten)"Google INC" ["version"]=>string(4)"49.0" ["majorver"]=>string(2)" the" ["Device_type"]=>string(7)"Desktop" ["Device_pointing_method"]=>string(5)"Mouse" ["Minorver"]=>string(1)"0" ["IsMobileDevice"]=>string(0)"" ["Istablet"]=>string(0)"" ["crawler"]=>string(0)""}
The following code can be used to determine whether a mobile browser:
<? PHP $ismobiledevice Get_browser ()IsMobileDevice; if ($ismobiledevice) { // mobile device- else { // PC-Side }
Reference:
<php cookbook>,3rd
Use PHP built-in function get_browser () to determine if it is a mobile browser