php - Head 标签显示在 CakePhp 的 body 内

标签 php html cakephp tags

我在 CakePhp 2.0 上遇到一个奇怪的错误,其中 head 标签呈现为空,并且属于 head 的所有标签都在任何内容之前呈现到正文中。

这就是布局 default.ctp 的样子:

<!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>
    <?php echo $this->Html->charset(); ?>
    <title>
        <?php echo $title_for_layout; ?>
    </title>
    <?php
        echo $this->Html->meta('icon');
        echo $this->Html->script(array('librerias/jquery.tools.min'));
        echo $this->Html->css('cake.generic');
        echo $this->Html->css('webfront');
        echo $scripts_for_layout;
    ?>
</head>
<body>
    <div id="container">
        <div id="header">
        </div>
(the rest of the html render)
</body>
</html>

这就是它的渲染方式,正如 firebug 所说:

<html xmlns="http://www.w3.org/1999/xhtml">
<head></head>
<body>
&#65279;&#65279;
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
    <title> Usuarios </title> **(IE moves the title tag on the head manually, it seems)**
    **(IE displays the DOCTYPE on its debugging console here)**
    <link rel="icon" type="image/x-icon" href="/web/favicon.ico">
    <link rel="shortcut icon" type="image/x-icon" href="/web/favicon.ico">
    <script src="/web/js/librerias/jquery.tools.min.js" type="text/javascript">
    <link href="/web/css/cake.generic.css" type="text/css" rel="stylesheet">
    <link href="/web/css/webfront.css" type="text/css" rel="stylesheet">
    <div id="container">
        <div id="header"> </div>
        (the rest of the html render)
</body>
</html>

这已经够糟糕的了,因为它扭曲了 DOCTYPE 标记并使 IE 渲染页面时出现很多错误。

此外,我还有另一个测试站点,不会发生此错误。事实上我切换了布局,错误是一样的。

有人知道为什么会发生这种情况吗?我在网上找不到类似的东西,对此我没有任何线索。任何帮助将不胜感激。

提前致谢

最佳答案

终于我们找到了这个问题的答案。这是Cake的php和utf-8编码上出现的臭名昭著的字符。通过更改最终布局之前通过的 php 文件的每个编码,我们解决了问题。

感谢您的帮助:)

关于php - Head 标签显示在 CakePhp 的 body 内,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10337532/

相关文章:

php - 是否有像 Google 提供网站图标这样的网站提供 apple-touch-icon 的服务?

php - 将大文本分成列

php - 如何在单列中获取多个复选框值

php - 在 Codeigniter 上使用 HIghcharts 获取数据名称和总数

html - 需要帮助使 div 垂直居中

javascript - 如何动态更改 HTML "a href"标签上的 "rect"链接?

php - AllowEmpty 与 NotEmpty

javascript - 相同的元素在溢出时具有不同的滚动高度。原因是什么?我该如何解决?

php - CakePHP 模型 : COUNT(*) in Containable

php - 在 CakePHP 中手动构建树