zend-framework - 如何回显 doctype,在 application.ini 中设置,在 zend 框架 View 中

标签 zend-framework doctype

在我的 Zend Framework 应用程序中,我想在我的 View 布局中回显文档类型:

<?= $this->doctype() . "\n"; ?>

我的 application.ini 中有以下几行:

resources.view[] =
resources.view.doctype = "HTML5"
resources.view.charset = "UTF-8"

这给了我:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

显然 application.ini 中的设置被忽略,取而代之的是使用默认的文档类型。

有没有办法在不使用 Bootstrap 的情况下在我的 View /布局中回显文档类型(我知道这行得通,但我不想让我的设置分散在 application.ini 和 Bootstrap 中)?

最佳答案

您需要在 bootstrap.php 中配置您的 View

protected function _initView()
{
    // Initialize view
    $view = new Zend_View();
    $view->doctype('XHTML1_TRANSITIONAL');
    $view->setEncoding('UTF-8');//per , htmlentities($str, ENT_QUOTES, "UTF-8");

    $view->headTitle('ABC');


    // Add it to the ViewRenderer
    $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
    $viewRenderer->setView($view);
    // Return it, so that it can be stored by the bootstrap
    return $view;
}

然后在布局或某些 View 中使用

echo $this->doctype();

关于zend-framework - 如何回显 doctype,在 application.ini 中设置,在 zend 框架 View 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7091133/

相关文章:

php - 我如何删除 Zend_Soap 中的 namespace ?

php - 如何在 Zend 中正确设置异常处理程序?

.htaccess - mod_rewrite 为域选择一个文件夹

php - 重构 Zend_Controller_Action

html-email - html电子邮件的文档类型

xhtml - 无效 XML 对严格 DOCTYPE 的 SEO 影响

java - 使用 DOM 解析 xml,DOCTYPE 被删除

php - 在 Zend Framework View 脚本中使用 baseUrl() 重要吗?

html - W3C 有效的 JQuery 表单验证器

html - DocType 导致 CSS 无法识别