Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/272.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 文件编码的更改会影响css显示html页面的方式吗?_Php_Html_Internet Explorer_Character Encoding_Smarty - Fatal编程技术网

Php 文件编码的更改会影响css显示html页面的方式吗?

Php 文件编码的更改会影响css显示html页面的方式吗?,php,html,internet-explorer,character-encoding,smarty,Php,Html,Internet Explorer,Character Encoding,Smarty,当我使用PHP Smarty时,这是一件奇怪的事情。 php文件的编码似乎会影响css PHP文件ANSI-test2.PHP <?php include_once("inc/smarty_inc.php"); $smarty->display('test.tpl.htm'); Smarty文件ANSI-test.tpl.htm <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www

当我使用PHP Smarty时,这是一件奇怪的事情。 php文件的编码似乎会影响css

PHP文件ANSI-test2.PHP

<?php
include_once("inc/smarty_inc.php");
$smarty->display('test.tpl.htm');
Smarty文件ANSI-test.tpl.htm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>JPR</title>
</head>
<body>
    <div style="width:500px;height:200px; background-color:Red;margin:auto;">
        test
    </div>
</body>
</html>
当这两个文件是ANSI时。div显示在页面的中心。IE和firefox都有

当其中一个转换为utf-8时。div显示在页面的左侧。只有在IE中,Firefox才可以


怎么了?如何在带有uff-8的IE中使其正常运行?

您将文件保存在带有BOM的UTF-8中,这将导致响应中的第一个字节是字节顺序标记的字节,而不是doctype。当IE没有首先看到doctype时,它会进入“怪癖”模式,在这种模式下,盒子的模型是不同的


您需要将其转换为不带BOM的UTF-8。这取决于您正在使用的文本编辑器或转换器。

如果您将文件保存为带BOM的UTF-8格式,这将导致响应中的第一个字节是字节顺序标记的字节,而不是doctype。当IE没有首先看到doctype时,它会进入“怪癖”模式,在这种模式下,盒子的模型是不同的


您需要将其转换为不带BOM的UTF-8。这取决于您使用的文本编辑器或转换器。

您如何在UTF-8中保存文件?如何在UTF-8中保存文件?