在我的 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/