note 59248 deleted from language.types.string by cmb
| From: | cmb@php.net | Date: | Thu, 18 Nov 2021 12:55:31 +0000 |
| Subject: | note 59248 deleted from language.types.string by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-217263@lists.php.net to get a copy of this message | ||
Note Submitter: webmaster at rephunter dot net
----
Use caution when you need white space at the end of a heredoc. Not only is the mandatory final
newline before the terminating symbol stripped, but an immediately preceding newline or space
character is also stripped.
For example, in the following, the final space character (indicated by \s -- that is, the
"\s" is not literally in the text, but is only used to indicate the space character) is
stripped:
$string = <<<EOT
this is a string with a terminating space\s
EOT;
In the following, there will only be a single newline at the end of the string, even though two are
shown in the text:
$string = <<<EOT
this is a string that must be
followed by a single newline
EOT;