I\'ve got a php file in which I want to comment out a block of code. The code is a mix of php and html with lots of to-and-fro between the two. Is there an easy way to comment out the block?
Buffistechnology 3: "Press Some Buttons, See What Happens."
Got a question about technology? Ask it here. Discussion of hardware, software, TiVos, multi-region DVDs, Windows, Macs, LINUX, hand-helds, iPods, anything tech related. Better than any helpdesk!
Gawd, I'm so rusty at php...
If you start a block comment in some php and end it in some other php, will the server just ignore everything in between? Or will it still send the html to the client?
Or will it still send the html to the client?
That\'s the problem -- it still sends the html to the client.
Then I think you'd have to comment out the php and html separately. I've had to do that with ASP.
That\'s what I was afraid of. It\'s a pain because there\'s a lot of back and forth, using php echo commands within the html. Eh, I\'ll just delete the code. I have a test version that still contains it.
Well, if you're just trying to not display the html generated by the php code (and the normal html), then using html-style comment tags will work:
< h t m l > < b o d y >
< ! - -
< ? = "hi"; ? >
< p >foo< / p >
< ? = "there" ? >
< p > asdf < / p >
- - >
< / b o d y > < / h t m l >
[spaces added to code to get it to play nice with b.org]
But if you're trying to comment out the php to prevent it from executing... yeah, offhand I'd say you'd have to comment separately.
Thanks, Eddie. That's better than nothing.
Got it!
To begin the "block comment" use:
< ? i f ( FALSE ) { ? >
then to end the "block comment" use:
< ? } ? >
Clever!
Um, is someone around to help me out? To save my brand-new monitor from being hurled through a wall?