无法在Zend Framework中获取doctype的输出

时间:2010-12-04 19:25:14

标签: php zend-framework

在我的bootstrap中,我有这段代码,

    $view = new Zend_View();
    $view->setEncoding('UTF-8');
    $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view);
    Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
    $viewRenderer->initView();
    $viewRenderer->view->doctype('XHTML1_TRANSITIONAL');
    Zend_Layout::startMvc(
                    array(
                        'layoutPath' => dirname(__FILE__) . '/layouts/scripts/'
                    )
    );

在我的layout.phtml中,我有,

<?php echo $this->doctype(); ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php $this->headTitle()->append('Site Title'); ?>
<?php echo $this->headTitle(); ?>
</head>
<body>
<div class="dp100">
<?php
echo $this->layout()->content;
?>
</div>
</body>
</html>

但是,我在最终的HTML页面中看不到预期的doctype声明。

1 个答案:

答案 0 :(得分:0)

咄!我正在检查Firebug中的源代码,它实际上隐藏了DOCTYPE声明,因为它没有在HTML文档中首先回显。在回显doctype之前,我已经回应了一个jquery include语句。

通过检查Firefox中的实际源代码找到解决方案。