Info
- 6 posts
- 2 voices
- Started 2 years ago by InvTrdr
- Latest reply from InvTrdr
- This topic is resolved
Skipping code in .php files and CSS.
-
- Posted 2 years 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.
Thank you. -
- Posted 2 years ago #
Yes, you can comment out a block of code in between the
<?phpand?>by using/* commented this part */. For example,<?php echo $user; /* 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.) -
- Posted 2 years ago #
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. -
- Posted 2 years ago #
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.
Thanks. -
- Posted 2 years ago #
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.
-
- Posted 2 years ago #
Thank you.
-
You must log in to post.