php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #43833 Configuration directive for PHP blocks eating newlines
Submitted: 2008-01-13 21:22 UTC Modified: 2018-05-05 19:31 UTC
Votes:6
Avg. Score:4.2 ± 1.5
Reproduced:5 of 5 (100.0%)
Same Version:1 (20.0%)
Same OS:1 (20.0%)
From: docuk at gmx dot net Assigned:
Status: Wont fix Package: *General Issues
PHP Version: 5.2.5 OS: All
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: docuk at gmx dot net
New email:
PHP Version: OS:

 

 [2008-01-13 21:22 UTC] docuk at gmx dot net
Description:
------------
Currently, PHP eats newlines following end tags as specified in the FAQ (http://us.php.net/manual/en/faq.using.php#faq.using.newlines). The documentation's justification for this feature is to make the HTML output more readable, but the reality is different (see Reproduce code section).

This is bearable because web browsers ignore this whitespace combination anyways, but for text output this causes a lot of headaches. I propose that the real reason for this feature is to prevent the "Headers already sent" error, such as in:

<?php /* some PHP code here */ ?>
<?php session_start(); ?>

PHP should have a configuration directive to disable this newline-stripping behavior, default to the old behavior for backwards compatibility if need be. This is way overdue.

References:

http://bugs.php.net/bug.php?id=20556
http://shiflett.org/blog/2005/oct/php-stripping-newlines
http://bradchoate.com/weblog/2007/05/10/php-and-newline-characters

Reproduce code:
---------------
<table> 
  <tr> 
    <td> 
      <?php echo 'TEST'; ?> 
    </td> 
  </tr> 
</table>

becomes

<table> 
  <tr> 
    <td> 
      TEST    </td> 
  </tr> 
</table>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-05-05 19:31 UTC] requinix@php.net
-Status: Open +Status: Wont fix -Package: Feature/Change Request +Package: *General Issues
 [2018-05-05 19:31 UTC] requinix@php.net
Adding an INI directive should involve discussion first. https://wiki.php.net/rfc/howto

Closing wontfix due to age and the rising popularity of templating over the last few years. This can be reopened if there's interest in the requested feature.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 01:01:31 2024 UTC