note 63707 added to language.types.string
| From: | bishop at osu1 dot php dot net | Date: | Tue, 28 Mar 2006 20:58:56 +0000 |
| Subject: | note 63707 added to language.types.string | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-106882@lists.php.net to get a copy of this message | ||
You may use heredoc syntax to comment out large blocks of code, as follows:
<?php
<<<_EOC
// end-of-line comment will be masked... so will regular PHP:
echo ($test == 'foo' ? 'bar' : 'baz');
/* c-style comment will be masked, as will other heredocs (not using the same marker) */
echo <<<EOHTML
This is text you'll never see!
EOHTML;
function defintion($params) {
echo 'foo';
}
class definition extends nothing {
function definition($param) {
echo 'do nothing';
}
}
how about syntax errors?; = gone, I bet.
_EOC;
?>
Useful for debugging when C-style just won't do. Also useful if you wish to embed Perl-like
Plain Old Documentation; extraction between POD markers is left as an exercise for the reader.
Note there is a performance penalty for this method, as PHP must still parse and variable substitute
the string.
----
Server IP: 64.71.164.2
Probable Submitter: 70.61.82.194
----
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/language.types.string.php
Edit -- http://master.php.net/note/edit/63707
Del: integrated -- http://master.php.net/note/delete/63707/integrated
Del: useless -- http://master.php.net/note/delete/63707/useless
Del: bad code -- http://master.php.net/note/delete/63707/bad+code
Del: spam -- http://master.php.net/note/delete/63707/spam
Del: non-english -- http://master.php.net/note/delete/63707/non-english
Del: in docs -- http://master.php.net/note/delete/63707/in+docs
Del: other reasons-- http://master.php.net/note/delete/63707
Reject -- http://master.php.net/note/reject/63707
Search -- http://master.php.net/manage/user-notes.php