PHP comments inside <? Php echo <<< EOF
You can not. The HEREDOC clause is that everything inside it will be part of the string. It exists to avoid PHP metadata (including comments), considered as such. Everything that you put inside it will appear on the line (and, thus, in this case it will be displayed wherever the output goes).
If the output is HTML, you can include HTML comment in it. It will still be displayed in the output, but anything that parses the HTML will treat it as a comment. Similarly, if the content is JS, then you can use JS comment, etc.
You cannot use a comment inside the heredoc syntax.
http://en.wikipedia.org/wiki/Here_document
This is a way to specify a literal string, literally.
It depends on the type of output echo ing. If you echo data to an HTML page, you can use the <!-- --> syntax and the browser will see this as a comment. If you output to a plaintext file, everything in heredoc will be output (in truth, everything will be output when writing HTML, just the browser will interpret the HTML comment).
When I use the heredoc syntax and you need to comment on the information inside, I usually use a (PHP-style) comment before heredoc and refer to any specific lines inside their line numbers relative to heredoc:
/* Write out default INI file. * L002: Log level. Possible values: debug,info,warning,error. */ echo <<<EOF [global] logging = error ... EOF Hope this helps.
As far as I know, you cannot leave comments inside the HEREDOC block. According to PHP documentation at http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc "Heredoc text behaves exactly like a double-quoted string without double quotes ".. and you can 'Add comments inside a line with two quotes.
Actually, there is a cool way of commenting inside an echo.
You can use the following syntax
<?php '.(/*comment here*/ NULL).' This line will be read as internal php and may contain comments. NULL must be included because everything inside the internal php requires a value. NULL is the most convenient choice, since you really do not want the value, just a comment.
Actually, you cannot use PHP comments in the middle of a line (neither in double quotes, nor in single quotes, nor in heredoc chains). They will be shown literally.
In some rare cases, it may be useful to simulate comments and separate them later from the line. For example, this can be useful if you are creating some kind of template engine. But, of course, in most cases you should not do this, as this is bad practice.
You can create your line using "\ r \ n" (using double quotes for line breaks) and put comments on the same line after the line, for example. echo "line1\r\nline2"; //this outputs two lines