Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php IE和兼容模式,为什么它会弄乱浏览器识别脚本?_Php_Internet Explorer_Ie8 Compatibility Mode - Fatal编程技术网

Php IE和兼容模式,为什么它会弄乱浏览器识别脚本?

Php IE和兼容模式,为什么它会弄乱浏览器识别脚本?,php,internet-explorer,ie8-compatibility-mode,Php,Internet Explorer,Ie8 Compatibility Mode,我在下面有一个脚本,它使用了$\u服务器['HTTP\u USER\u AGENT'],因为get\u browser()在服务器上未处于活动状态,并且所述服务器的管理员(hotgator)不会为我激活它 也就是说,当我在兼容模式下运行IE8时,我正在WindowsXP(虚拟机测试床)中运行IE8,IE在下面的脚本中显示为IE7,而不是IE8。为什么? <?php //This is a script that will identify the OS and browser you ar

我在下面有一个脚本,它使用了
$\u服务器['HTTP\u USER\u AGENT']
,因为
get\u browser()
在服务器上未处于活动状态,并且所述服务器的管理员(hotgator)不会为我激活它

也就是说,当我在兼容模式下运行IE8时,我正在WindowsXP(虚拟机测试床)中运行IE8,IE在下面的脚本中显示为IE7,而不是IE8。为什么?

<?php
//This is a script that will identify the OS and browser you are using.
// This also has a fix in where Chrome shows up as Chrome, 
// and not show up as Safari by accident. 



//Booleans to set OS and Browser to False.
$os = false;
$browser = false;
//Booleans for Web Browser & OS Functions.
$info = $_SERVER['HTTP_USER_AGENT'];
$xp = 'Windows NT 5.1';
$vista = 'Windows NT 6.0';
$win7 = 'Windows NT 6.1';
$ubuntu = 'Ubuntu';
$ie106 = 'ie106';
$ie10 = 'ie10';
$ie9 = 'ie9';
$ie8 = 'MSIE 8.0;';
$ie7b = 'MSIE 7.0b;';
$ie7 = 'MSIE 7.0;';
$chrome = '/Chrome/';
$safari = '/Safari/';
$firefox = '/Firefox/';


//Operating Systems
if (stristr($info, "Windows NT 5.1")) {echo 'You are using a Windows XP Operating System ';}
if (stristr($info, "Windows NT 6.0")) {echo 'You are using a Windows Vista Operating System ';}
if (stristr($info, "Windows NT 6.1")) {echo 'You are using a Windows 7 Operating System ';}
if (stristr($info, "Ubuntu")) {echo 'You are using an Ubuntu Operating System ';}
if (stristr($info, "Mac OS")) {echo 'You are using a Macintosh Operating System ';}


//Web Browsers
if (stristr($info, "Chrome") !== FALSE) {stristr($info,"Safari");
        $chrome = 'Chrome';
            echo 'with a Chrome Web Browser ';}
elseif (stristr($info, "Safari")) {echo 'with a Safari Web Browser ';}
if (stristr($info, "Firefox")) {echo 'with a Firefox Web Browser ';}
if (stristr($info, "MSIE 7.0;")) {echo 'with a Internet Explorer 7.0 Web Browser ';}
if (stristr($info, "MSIE 7.0b;")) {echo 'with a Internet Explorer 7.0b Web Browser ';}
if (stristr($info, "MSIE 8.0;")) {echo 'with a Internet Explorer 8.0 Web Browser ';}
if (stristr($info, "MSIE 9.0;")) {echo 'with a Internet Explorer 7.0 Web Browser ';}
if (stristr($info, "MSIE 10.0;")) {echo 'with a Internet Explorer 7.0 Web Browser ';}
if (stristr($info, "MSIE 10.6;")) {echo 'with a Internet Explorer 7.0 Web Browser ';}



//If OS or Browser not found in list.
if ($ubuntu || $xp || $vista || $win7)
$os = true;

if($firefox || $chrome || $safari || $ie9 || $ie8)
$browser = true;

if(!$browser || !$os){

echo'<strong>';
echo '<br />' . $_SERVER['HTTP_USER_AGENT'] . '<br />Please copy and paste the text above and send it to your web administrator. It will explain everything he/she needs to do.';}

?>

我相信“兼容性模式”完全模拟了IE7,这就是为什么它这么叫的原因。为什么——问问女士。

我相信“兼容性模式”完全模仿IE7,这就是为什么它这么叫。原因-询问女士。

这是因为在兼容模式下,IE8会返回到IE7渲染,以便与专为较旧浏览器设计的站点兼容。因此,它需要向web服务器标识自己,这样,如果站点为不同版本的web浏览器提供不同的内容,它们就会返回正确的内容


兼容模式为。

这是因为在兼容模式下,IE8会返回到IE7呈现,以便与专为旧浏览器设计的站点兼容。因此,它需要向web服务器标识自己,这样,如果站点为不同版本的web浏览器提供不同的内容,它们就会返回正确的内容


兼容模式为。

因为在兼容模式下运行Internet Explorer 8(和9,通常情况下)与运行Internet Explorer 7相同?因为IE7仿真模式会导致浏览器模拟IE7:),因为运行Internet Explorer 8(和9,通常情况下)“在兼容模式下”与“运行Internet Explorer 7”相同?因为IE7模拟模式会使浏览器模拟IE7:),如果它以与IE7相同的方式呈现页面,这可能会非常有用。@DampeS8N没错,它只模拟IE7,而不是尽我所能实际使用原始IE7呈现引擎请参阅我答案中的链接文章。@DampeS8N同意-你在这里向唱诗班布道。@MattRidge除非浏览器会播放一些内容。如果它不在用户代理字符串中,那么我看不出如何使用PHP找到它。也许你可以访问一些JS变量集,但我对此表示高度怀疑。如果它将页面呈现为与IE7相同的样子,那么这可能真的很有用。@DampeS8N没错,它只是模仿IE7,而不是从我在回答中的链接文章中看到的实际使用原始IE7呈现引擎。@DampeS8N同意-你在这里向唱诗班布道。@MattRidge除非浏览器如何播放这个。如果它不在用户代理字符串中,那么我看不出如何使用PHP找到它。也许您可以访问一些JS变量集,但我非常怀疑。