I am using $ _SERVER ['HTTP_USER_AGENT'] to detect a custom browser. When I run var_dump on my localhost in IE8, it returns: ... compatible; MSIE 8.0; ... But when I download it to my host (godaddy), I get: ... compatible; MSIE 7.0; ...
What is the problem?
Check the word TRIDENTon the line. Compatibility is in compatibility mode. Google if you want to know what that means. However, the term trident is only ie8 +.
TRIDENT
: , /, ie8- ( ). , , . Google .
$_SERVER ['HTTP_USER_AGENT']
, . .
User-Agent string-hacking - . , .
User-Agent
: IE8, , IE7. Trident/... , , , , , , , User-Agent IE , , , , , .
Trident/...
, , HTTP , , , - , Vary . , IE.
Vary
UA - , , - . IE .
get_browser() , .
get_browser()
:
<?php echo $_SERVER['HTTP_USER_AGENT'] . "\n\n"; $browser = get_browser(null, true); print_r($browser); ?>
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040803 Firefox/0.9.3 Array ( [browser_name_regex] => ^mozilla/5\.0 (windows; .; windows nt 5\.1; .*rv:.*) gecko/.* firefox/0\.9.*$ [browser_name_pattern] => Mozilla/5.0 (Windows; ?; Windows NT 5.1; *rv:*) Gecko/* Firefox/0.9* [parent] => Firefox 0.9 [platform] => WinXP [browser] => Firefox // ...
preg_match('/MSIE (.*?);/', $_SERVER['HTTP_USER_AGENT'], $matches); echo $version = $matches[1];
Source: https://habr.com/ru/post/1754035/More articles:iPhone NSDateComponent is incorrect Date 1.1.2011? - iphoneHow to create a SystemSoundID array - objective-cModeling side effects using threads - functional-programmingCx_Oracle problem trying to import python - pythonHow to create a SystemSoundID array? Using AudioToolbox Infrastructure - objective-cDetect IE compatibility mode only with PHP - phpAndroid configuration screen during installation - androidКак использовать пользовательскую Android ViewGroup в XML? - androidNinject how to access the kernel for instantiation? - asp.net-mvcGroup a collection of items in Colorbox - jqueryAll Articles