Yes, you can comment out a block of code in between the
?> by using
/* commented this part */. For example,
/* echo $phone; */
The phone would no longer be displayed because you commented it out. It won’t even appear in the source of the page when viewed in the browser, unlike a HTML comment
<!-- commented this part --> or CSS comments (which are always visible.)
For a single line of PHP, you can just do this:
// echo $phone;
And that single line will be commented out. If what you’re commenting spans more than one line, use the
/* commented code */ method.
Thanks. I will ahve to try it again as once when I used it in my footer.php I actually saw the /* and */ on the page itself. I might have inserted it the wrond way.
It definitely needs to be inside the
<?php ?> code block, or it’s just HTML to the browser. You probably didn’t have it in a code block if you saw it displayed.
A syntax highlighting editor helps a lot with this. It helps you see what is code and what is plain text.
13 years, 5 months ago
In CSS I use /*………*/ for a few lines of code or ……..// for just a line so that code is skipped or avoided. Will this work in a .php file also? I would like to skip code to test it out without deleting the original code. Just want to mask the original code so I can go back to it if I make a mistake.