note 76247 added to language.types.string
| From: | michael at mahemoff dot com | Date: | Sat, 07 Jul 2007 07:51:56 +0000 |
| Subject: | note 76247 added to language.types.string | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-128281@lists.php.net to get a copy of this message | ||
Heredocs can be used for more than just echoing or setting variables - use them whenever you want to
include a string.
function header() {
return <<<EOT
<html>
<head>
<title>This is my heredoc</title>
</head>
<body>
EOT;
Also, note the strict syntax:
- No semicolon after initial EOT (think of the heredoc as a literal string arg - you wouldn't
want a semicolon in front of it, would you?)
- BUT need semicolon after final EOT (the command is finished here)
- Final EOT is on the left margin - don't indent it!
----
Server IP: 216.235.15.211
Probable Submitter: 87.194.3.55
----
Manual Page -- http://www.php.net/manual/en/language.types.string.php
Edit -- https://master.php.net/note/edit/76247
Del: integrated -- https://master.php.net/note/delete/76247/integrated
Del: useless -- https://master.php.net/note/delete/76247/useless
Del: bad code -- https://master.php.net/note/delete/76247/bad+code
Del: spam -- https://master.php.net/note/delete/76247/spam
Del: non-english -- https://master.php.net/note/delete/76247/non-english
Del: in docs -- https://master.php.net/note/delete/76247/in+docs
Del: other reasons-- https://master.php.net/note/delete/76247
Reject -- https://master.php.net/note/reject/76247
Search -- https://master.php.net/manage/user-notes.php