ID: 20814 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] -Status: Analyzed +Status: Closed Bug Type: Documentation problem Operating System: all PHP Version: 4.4.0-dev New Comment:
This behavior has now been documented: http://cvs.php.net/cvs.php/phpdoc/en/language/types.xml Thanks for the report :) Previous Comments: ------------------------------------------------------------------------ [2003-01-21 00:45:31] [EMAIL PROTECTED] This has been documented but it could also mention, that if the end tag of heredoc is not 'clean', ie. it's not exactly 'heredoc;' like in the example above, then it is NOT considered the end tag. ZE will ignore it and continued looking for the end tag.. and as it is not found, there will be a parse error, with line number being the last line of the script. ------------------------------------------------------------------------ [2002-12-04 14:58:11] [EMAIL PROTECTED] To clarify the line mismatch: AFAIK it's the same as a missing '}' in if/else. It will report on the __last__ expected '}', while the error will intuitively start on the __first__ unclosed '}'. The '$' is 'end' as in regexps. ------------------------------------------------------------------------ [2002-12-04 11:24:55] [EMAIL PROTECTED] To clarify a few points: a) This is known and is both documented and is a current feature request: http://bugs.php.net/bug.php?id=8685 http://www.php.net/language.types.string#language.types.string.syntax.heredoc b) The error that's reported is odd, and looks something like this: Parse error: parse error, unexpected $ in test.php on line 42 Where 42 is, for example, on the last line of test.php even when the error is elsewhere. This error sorta makes sense in most cases (like a missing quote or closing brace) but IMHO not here. Maybe someone can briefly explain what PHP is thinking. c) Many have attempted to fix this and many more have reported it (a) but it appears to be almost impossible to fix and remains a feature request. Again, it is documented with a big fat warning. Am leaving as open as this mentions the strange error too (b), not just the known feature request. ------------------------------------------------------------------------ [2002-12-04 11:23:05] [EMAIL PROTECTED] [quick on the trigger]... scratch that last sentence ... I was going to point out that the closing tag has to be flush left but I think that is not a bug. ------------------------------------------------------------------------ [2002-12-04 11:04:39] [EMAIL PROTECTED] I've tested this on PHP 4.2.3 for OSX, Open BSD, Linux... If you leave any whitespace after the closing tag of a here document structure (not sure if that's what it is called, like in Perl) a parse error will occur but never for the correct line. This seems like a bug to me because a semi- colon should terminate the code allowing the programmer to put comments or whatever after the semi-colon. Here is an example: $variable = "variable"; $someVariable = <<<hereDocument <html> <body> <b>text text $variable testing here document</b> </body> </html> hereDocument; // closing comment or just whitespace echo $someVariable; After the closing "hereDocument;" if you leave any whitespace (other than a carriage return) or text, a parse error is generated but the line number never leads you to the right place. This can be very confusing if you are working on a large class (like I was) and you left a tab or space after a closing tag. I'm not sure how consciously supported the here document structure is but this is worth addressing since here documents can be very useful for storing large variables containing HTML code with double and single quotes, for example. While I'm submitting this bug, I might as well point ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=20814&edit=1 -- PHP Documentation Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php