From:             iwd32900 at yahoo dot com
Operating system: Darwin/Mac OS X
PHP version:      4.3.4
PHP Bug Type:     Documentation problem
Bug description:  HEREDOC linefeed requirement mis-documented

Description:
------------
The current manual says this, under the "Heredoc" 
section in "Strings" in "Types":

-----
It's also important to realize that the first character 
before the closing identifier must be a newline as 
defined by your operating system. This is \r on 
Macintosh for example.

If this rule is broken and the closing identifier is not 
"clean" then it's not considered to be a closing 
identifier and PHP will continue looking for one. If in 
this case a proper closing identifier is not found then 
a parse error will result with the line number being at 
the end of the script.
-----

I have two issues with this.
1. This doesn't appear to be true. I'm using the 
entropy.ch distribution of 4.3.4, and it accepts \n as a 
linefeed before the end marker on my Mac.

2. One of the great things about PHP is that it's cross-
platform portable. The interpretter otherwise seems to 
be linefeed-agnostic; it should be here, too. That way, 
I can write my scripts on any platform and distribute 
them to any other, and no one has to worry about 
something as irritating as linefeeds. Just check for any 
of \n, \r, or \r\n before a heredoc terminator. Should 
be really easy, and it will do a lot for making PHP more 
platform independent.

Reproduce code:
---------------
$heredoc = <<<HEREDOC
    Does this cause a parse error?
HEREDOC;
echo $heredoc;

// No, it doesn't

Expected result:
----------------
Given what the manual says, this should break since the 
linefeeds are Unix but it was run on a Mac.

The documented behavior isn't the DESIRABLE behavior, 
however. PHP should accept all linefeed types on all 
platforms to promote code portability.

Actual result:
--------------
The example works just fine on my Mac, actually. It may 
be that the cross-platform behavior is already 
implementd, and just hasn't been documented yet.

-- 
Edit bug report at http://bugs.php.net/?id=26582&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=26582&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=26582&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=26582&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=26582&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=26582&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=26582&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=26582&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=26582&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=26582&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=26582&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=26582&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=26582&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26582&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=26582&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=26582&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=26582&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=26582&r=float

Reply via email to