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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
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: Sun May 05 22:01:29 2024 UTC