Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP - Comments inside <?php echo <<<EOF

Tags:

comments

php

How do I comment out if I use this syntax?:

<?php
            echo <<<EOF

    Is it //Comment or <!-- Comment --> or something else?    

            EOF;
            ?>

I'm a little bit confused. Thank you

like image 370
Uli Avatar asked Jul 01 '11 15:07

Uli


2 Answers

You can't. The point of HEREDOC is that anything inside it will be part of the string. It exists to avoid having PHP meta characters (including comments) treated as such. Anything you put inside it will appear in the string (and thus, in this instance, be echoed to wherever the output is directed).

If the output is HTML, then you could include an HTML comment in it. That will still appear in the output, but anything parsing the HTML will treat it as a comment. Likewise, if the content is JS then you can use a JS comment, and so on.

like image 64
Quentin Avatar answered Sep 20 '22 02:09

Quentin


You can't use a comment inside the heredoc syntax.

http://en.wikipedia.org/wiki/Here_document

It's a way to specify a literal string, literally.

like image 26
Fosco Avatar answered Sep 20 '22 02:09

Fosco