How do HTML comments work with PHP code?

I'm just wondering how the HTML tag works with php code.

If I have the following code, does php still parse it?

<!--
<?php
   echo "hi";
?>
-->

simple question, but I think it is important to know.

+3
source share
3 answers

Oh yes, something in the PHP blocks is executed, but in this case it is not displayed to the end user, because it is in the HTML comments.

In the original page of the page created by this PHP script, you will see the result surrounded by HTML comments, just like that.

The only way comments will affect the output of a PHP script with valid PHP comments.

+18
source

Yes Yes. If it's between the tags<?php ?>

PHP /* commment */, .

+4

: HTML:

<!--
  <?php
    echo "-->This will be seen!<!--";
  ?>
-->

:

<!--
  -->This will be seen!<!---->
+4

Source: https://habr.com/ru/post/1730203/


All Articles