【问题标题】:Text in html file is displayed but html tags are being ignored显示 html 文件中的文本,但 html 标记被忽略
【发布时间】:2014-12-01 18:16:42
【问题描述】:

我有一个 test.php 文件,其中包含:

<HTML>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<?php include('text.html'); ?>
</body>
</html>

包含的文件包含带有各种 html 标签的 html 格式文本。 执行 test.php 时,包含的文本被显示,但 html 标签没有格式化输出,但像在源中一样可见。另外,utf-8 特殊字符也没有正确显示

示例:�h3> (1880, Bucure_ti - 1970, Bucure_ti)

如果我不使用包含但我只是将包含文件的内容直接粘贴到源代码中,则输出很好。 我也尝试使用我在这个网站上找到的以下代码,而不是包含,但结果是一样的:

<?php  

$f = fopen("bio.php", "r");

// Read line by line until end of file
while(!feof($f)) { 
    echo fgets($f) . "<br />";
}

fclose($f);
?>

What is wrong ?``

【问题讨论】:

    标签: php html tags inclusion


    【解决方案1】:

    text.html 和/或test.php 是/未在UTF-8 中编码,正如您的元标记所声称的那样。将它们都编码为UTF-8。如果您仍然遇到问题,请将它们编码为UTF-8 w/o BOM。 (字节序标记)

    【讨论】:

      猜你喜欢
      • 2012-03-13
      • 1970-01-01
      • 2021-10-09
      • 2021-05-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-28
      相关资源
      最近更新 更多