note 105835 deleted from language.types.string by googleguy

From: Date: Mon, 11 Feb 2013 05:12:06 +0000
Subject: note 105835 deleted from language.types.string by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-193576@lists.php.net to get a copy of this message
Note Submitter: MarkSG ---- Actually, HEREDOC works precisely as documented, with nothing hidden at all. It's just that it's one of those things which isn't entirely intuitive to grasp. A HEREDOC block has to start with the delimiter followed by a newline, and end with a newline followed by the delimiter. That means that the leading and trailing newlines are part of the syntax, not a part of the block. So this <?php $foo = <<<EOF this is a block EOF; ?> is equivalent to this <?php $foo = "this is a block"; ?> or this <?php $foo = "this\nis\na\nblock"; ?> but not this: <?php $foo = " this is a block "; ?> or this <?php $foo = "\nthis\nis\na\nblock\n"; ?> Viewing it with the syntax highlighting switched on helps to make the difference clearer.

« previous php.notes (#193576) next »