Bug #13610 Updated: heredoc: any chars (even white space) after closing ";" causes error

From: Date: Tue, 09 Oct 2001 21:59:30 +0000
Subject: Bug #13610 Updated: heredoc: any chars (even white space) after closing ";" causes error
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-67643@lists.php.net to get a copy of this message
ID: 13610 Updated by: jeroen Reported By: rprangnell@hotmail.com Status: Open Bug Type: Feature/Change Request Operating System: Windows98 PHP Version: 4.0.6 New Comment: Patch available here: http://www.A-Eskwadraat.nl/~jeroen/php/looser_heredoc.diff which changes behaviour to: A heredoc is considered closed when the heredoc identifier appears directly after a newline. Remaining characters are allowed, provided they are invalid identifyer characters. Example: <?php mail('jeroen@php.net', 'heredoc test', <<<TEXT Hello Jeroen, Greets! TEXT, 'Cc: bla@example.com'); ?> And this works: <?php echo <<<HEREDOC bla HEREDOCUMENTATION; HEREDOC; // here the heredoc ends ?> But this doesn't: <?php echo <<<HEREDOC bla HEREDOC UMENTATION; HEREDOC; ?> for the same reason as this is: echo "bla" UMENTATION; causes a parse error. Previous Comments: ------------------------------------------------------------------------ [2001-10-09 16:27:02] jeroen@php.net This behaviour is documented in the strings section, subsection heredoc. I agree that this is quite annoying and strange. It can be easily modified, for example to allow anything afterwards. But this could break BC (though not likely): $bla = <<<HEREDOC Text text HEREDOC is great! text HEREDOC; Other solutions would be quite arbirary (as is the current solution by the way). Most consistent would be allowing a heredoc-string at all places where a quoted string is also allowed. ------------------------------------------------------------------------ [2001-10-09 06:10:40] derick@php.net It is expected behavior. Although I agree it is not very handy that this is not possible. Making this a feature request. Derick ------------------------------------------------------------------------ [2001-10-09 06:07:02] rprangnell@hotmail.com Having carefully searching the bugs database and drawn a blank on this( I made sure to include 'closed' and 'bogus' entries in my search!), I would like to point out that the new 'heredoc' syntax (which is GREAT) has a little bug that could prove troublesome as it is hard to spot. The bug is that you can't put anything other than the 'return' character after the semi-colon that closes the statement. Even a single white space character after the semi-colon forces a parse error. This can be a poser, especially if the user's editor can't display non-printing characters. Typically, this kind of thing won't work: $query = <<< SQL SELECT parentID FROM messages WHERE msgID = $msgID SQL; // Can't put a comment (or anything else) here! I encountered the same bug with both the PWS and the Apache ISAPI module version. ------------------------------------------------------------------------ Edit this bug report at http://bugs.php.net/?id=13610&edit=1

« previous php.dev (#67643) next »