|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30384 PHP's HTML parser eats linefeeds
Submitted: 2004-10-10 19:31 UTC Modified: 2004-10-10 21:56 UTC
From: septh at freesurf dot fr Assigned:
Status: Not a bug Package: Output Control
PHP Version: 4.3.9 OS: Windows XP Pro
Private report: No CVE-ID: None
 [2004-10-10 19:31 UTC] septh at freesurf dot fr
When parsing HTML source code, PHP seems to "eat" the linefeed after the ?> marker.

Tested on Windows XP Professional SP1 with Apache 1.3.31 and PHP 4.3.9. Unfortunately, I can't test it with any other versions (I do not have administrator access to the machine).

Reproduce code:
File test.php :

<pre style="border: 1px solid black;">
line 1
<?php echo "line 2"; ?>
line 3
<?php echo "line 4"; ?>
line 5

Expected result:
line 1
line 2
line 3
line 4
line 5

Actual result:
line 1
line 2line 3
line 4line 5

Note 1: Ok, I realize there are no "\n" ni my echo statements. However, there *is* a linefeed after each ?> in the HTML code, and I wouldn't expect PHP to remove them.

Note 2: by adding an extra character after the ?> (say, a space char), the ouput is correct.

Note 3: the problem arises whether I save the test.php file with PC-style (\n), Unix-style (\r\n), or Mac-style (\r) linefeeds.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-10-10 21:56 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

It\'s documented behaviour.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 05:01:28 2024 UTC