#13954 [Com]: newline is stripped after the closing ?>
| From: | hz11 at nyu dot edu | Date: | Sat, 25 Jan 2003 23:23:17 +0000 |
| Subject: | #13954 [Com]: newline is stripped after the closing ?> | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-31247@lists.php.net to get a copy of this message | ||
ID: 13954
Comment by: hz11@nyu.edu
Reported By: aln00@udcast.com
Status: Bogus
Bug Type: *General Issues
Operating System: linux 2.2.19
PHP Version: 4.0.6
New Comment:
I'd like another look at this issue, since the documentation seems to
clash with actual behavior.
Using a CLI compiled 4.3.0 binary, this script:
#!/bin/psh
<?php
$foo = 'Hello';
$bar = 'World';
?>
<?=$foo?>
<?=$bar?>
<?php
echo 'DONE!';
?>
This script will produce:
<empty line>
HelloWorld
DONE![unix prompt]$
Note that there is no trailing space (x20) after <?=$foo?> and
<?=$bar?> - only a newline (x0A)
According to
http://www.php.net/manual/en/language.basic-syntax.php#language.basic-syntax.phpmode
"The closing tag for the block will include the immediately trailing
newline if one is present."
Now if I add a x20 after the closing tag, then the newlines is honored.
Why does this behavior make any sense? Especially since the
aforementioned URL has statements like "...because when PHP hits the ?>
closing tags, it simply starts outputting whatever it finds until it
hits another opening tag" throughout. Obviously, however, this isn't
true, since PHP decides to ignore the newline immediately after the
closing tag.
I don't understand why this behavior would be desired anyway; what is
outside the PHP tags should simply be passed through. And especially
since the docs are misleading about this.
Thank you,
Hans
Previous Comments:
------------------------------------------------------------------------
[2001-11-06 15:10:13] jeroen@php.net
This is documented behaviour, and with a reason (to allow better
formatting of php code without ruining the layout of the output)
RTFM:
http://uk.php.net/manual/en/language.basic-syntax.php#language.basic-syntax.phpmode
(admittingly, it's just a very small sentence...)
------------------------------------------------------------------------
[2001-11-06 10:37:46] aln00@udcast.com
Hello,
I'm using php as a powerful generic macro processor for ascii files,
which contains some php code. Everything is OK, except a very annoying
problem when the php code generates nothing. For example:
--------- FILE 1 ---------
var0 = "a constant string"
var1 = <?= $hh1 ?>
var2 = <?= $hh2 ?>
var3 = "another constant string"
---------------------------
with $hh1 and $hh2 empty will generate:
---------------------------
var0 = "a constant string"
var1 = var2 = var3 = "another constant string"
---------------------------
instead of :
---------------------------
var0 = "a constant string"
var1 =
var2 =
var3 = "another constant string"
---------------------------
NB: If I put a space after the ?>, the newline is not stripped.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=13954&edit=1