Php Zend layout.html输出的换行符和白线

Php Zend layout.html输出的换行符和白线,php,zend-framework,zend-layout,Php,Zend Framework,Zend Layout,根据Zend框架标准,我使用Zend_布局 zf create project demo cd demo zf enable layout 就这样 这是我的配置: [production] phpSettings.display_startup_errors = 0 phpSettings.display_errors = 0 includePaths.library = APPLICATION_PATH "/../library" bootstrap.path = APPLICATIO

根据Zend框架标准,我使用Zend_布局

 zf create project demo
 cd demo
 zf enable layout
就这样

这是我的配置:

[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0

resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
[staging : production]

[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1
以下是layout.phtml中的情况:

<?= $this->doctype() ?>

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>  
      <?= $this->headMeta(); ?>


      <?= $this->headTitle(); ?>

    </head>
产出:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head>  <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />      <title>Dashboard</title>       </head>
我的问题是,所有的断线和白线都被删除了。我怎样才能把它们拿回来

但是,echo$this->layout->content的输出仍然是虚线和白线

<?= $this->doctype() ?>

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>  
  <?= $this->headMeta(); ?>

  <?= $this->headTitle(); ?>

</head>

只需在视图帮助程序后添加空行即可。

setIndent、setPostfix和不太关心缩进和新行似乎是答案,但我不喜欢这样

setIndetn和setPostfix在他们的手册中有所解释,助手从类占位符继承这些方法

导致不太好的html源代码的用法示例:

<?php echo $this->doctype(); ?> <html> <head> <?php echo $this->headMeta()->setIndent( ' ' )->setPostfix( "\n" ); echo $this->headTitle()->setIndent( ' ' )->setPostfix( "\n" ); # ... 供参考;在其他页面中,我阅读了以下部分:


.

在您的案例中,Zend或PHP不会删除这些内容。最有可能的是,这些都被您查看源代码的程序删除了。只要将您的系统配置为正确处理换行符,您就应该没事了,可能是UNIX或OSX换行符,但您可以在windows编辑器中查看源代码?@hakre我在unbutu的VIM中查看源代码。这并不能解释html之后和head之前缺少换行符的原因,所以我想这不是一个解决方案。有一次它帮助我解决了同样的问题,所以我只是分享一些经验,它可以解决类似的问题,但我认为这不是OP的问题,仅此而已。考虑到我们讨论的是结果HTML,断行消失不是问题。@balkon_smoke$this->doctype。PHP_EOL更好,但我的问题是白线也被删除了。我想是某种zend过滤器把它们去掉。