note 10192 added to echo
| From: | tbutzon at imawebdesigner dot com | Date: | Tue, 19 Dec 2000 03:00:35 +0000 |
| Subject: | note 10192 added to echo | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-8867@lists.php.net to get a copy of this message | ||
Echo and here-doc can be very handy, but you need to know two important things on top of from
syntax.
Follow this basic syntax...
echo <<<EOT
My name is $name.
My second child's name is {$children[2]['name']}.
EOT;
Two important things to note:
(1) Whitespace after "echo <<<EOT" can lead to an error like this:
...expecting
','' or ';''...
So it's important to start a new line DIRECTLY after the first EOT.
(2) Placing the terminating EOT on any column other than the very first of a line can yield errors
reported on lines that are really fine... the error may look like this:
...parse error, expecting T_STRING' or T_VARIABLE' or...
So it's also important to put EOT at the very beginning of a line.
Take a look at http://www.php.net/manual/html/language.types.string.html#AEN2504
for more information.
http://www.php.net/manual/function.echo.php