Does someone know more about it? I just can see that in
zend_language_scanner.l are these rules:
NEWLINE (\r|\n|\r\n)
ST_IN_SCRIPTING{TABS_AND_SPACES}{LABEL}{NEWLINE} {
...
BEGIN(ST_HEREDOC);
...
}
ST_HEREDOC^{LABEL}(;)?{NEWLINE} {
...
BEGIN(ST_IN_SCRIPTING);
...
}
It seems that it was intended to accept all types of newlines but \r
is not accepted on Linux/Windows nor on MacOS (maybe only X) in fact.
Jakub Vrana
ID: 26582
User updated by: iwd32900 at yahoo dot com
Reported By: iwd32900 at yahoo dot com
-Status: No Feedback
+Status: Open
Bug Type: Documentation problem
Operating System: Darwin/Mac OS X
PHP Version: 4.3.4
New Comment:
No, it doesn't work with \r.
I realize that in some sense, \n is the new 'native'
linefeed for Mac since OS X is Unix based. This doesn't
change my opinion that PHP should be linefeed-agnostic,
so that code can easily be transported from one platform
to another.
Previous Comments:
[2003-12-18 05:21:18] [EMAIL PROTECTED]
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to Open. Thank you.
[2003-12-10 09:39:06] [EMAIL PROTECTED]
Does heredoc work for you with \r?
[2003-12-10 09:12:36] iwd32900 at yahoo dot com
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.