note 64378 added to function.echo
| From: | PHPer at osu1 dot php dot net | Date: | Thu, 13 Apr 2006 05:03:23 +0000 |
| Subject: | note 64378 added to function.echo | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-107955@lists.php.net to get a copy of this message | ||
"This is a beauty for lots of text, really. And easy to read, if you're a PERL or shell
person.
echo <<<END
This uses the "here document" syntax to output
multiple lines with $variable interpolation. Note
that the here document terminator must appear on a
line with just a semicolon. no extra whitespace!
END; "
I just wanted to note that the last line "END;" must not have any whitespace before it..
so if your echo statement is indented, which 99% of the time it would be, make sure the echo
terminator is not indented at all
This can also be used in variable assignments.. like SQL statements.
$SQL = <<<END
SELECT * FROM MyTable
WHERE UserID = $UserID
END;
But then, I don't see the benifit of doing that vs...
echo "
This uses the "here document" syntax to output
multiple lines with $variable interpolation. Note
that the here document terminator must appear on a
line with just a semicolon. no extra whitespace!";
or
$SQL = "
SELECT * FROM MyTable
WHERE UserID = $UserID";
-PHPer
----
Server IP: 66.163.161.117
Probable Submitter: 71.252.152.37
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.echo.php
Edit -- http://master.php.net/note/edit/64378
Del: integrated -- http://master.php.net/note/delete/64378/integrated
Del: useless -- http://master.php.net/note/delete/64378/useless
Del: bad code -- http://master.php.net/note/delete/64378/bad+code
Del: spam -- http://master.php.net/note/delete/64378/spam
Del: non-english -- http://master.php.net/note/delete/64378/non-english
Del: in docs -- http://master.php.net/note/delete/64378/in+docs
Del: other reasons-- http://master.php.net/note/delete/64378
Reject -- http://master.php.net/note/reject/64378
Search -- http://master.php.net/manage/user-notes.php