#20814 [Opn]: reproducable, freaky parse error in 'here document' structure

From: Date: Wed, 04 Dec 2002 17:23:05 +0000
Subject: #20814 [Opn]: reproducable, freaky parse error in 'here document' structure
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-26637@lists.php.net to get a copy of this message
ID: 20814 User updated by: kumar@chicagomodular.com Reported By: kumar@chicagomodular.com Status: Open Bug Type: Scripting Engine problem Operating System: several PHP Version: 4.2.3 New Comment: [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. Previous Comments: ------------------------------------------------------------------------ [2002-12-04 11:04:39] kumar@chicagomodular.com 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

« previous php.bugs (#26637) next »