Page 1 of 1
Do you always close your <?php blocks?
Posted: Fri Aug 23, 2002 11:18 pm
by nielsene
So after posting some of my code for illustration purposes,
hob_goblin pointed out that either the display was cut-off or the file was missing its close '?>'. Looking over my other files, I noticed that I almost never close the php blocks in my libraries/classes. I know that php automatically drops into html mode on a new file so this isn't a real problem.
I could make the arguement that it makes it easier to avoid a stray newline at the end of the file wrecking havoc with later headers.
Or am I just trying to justify laziness/sloppy coding

?
Posted: Fri Aug 23, 2002 11:26 pm
by protokol
lazy, sloppy, and frowned upon .. if you open a <?php end somewhere with a ?>
Posted: Fri Aug 23, 2002 11:27 pm
by phice
For some reason, when I forget to add my ?>, it quits with an error.
Posted: Sat Aug 24, 2002 3:04 am
by Takuma
Have you got any HTML code after the place where you meant to have put the ?>?
good thing to remember
Posted: Sat Aug 24, 2002 3:59 am
by conthox
A good thing to remember is to always do a end tag for your code, nomatter if it is a PHP or JavaScript or HTML or something else.
In the future, the XHTML and XML langugage maybe is the thing - and it demands stop-tags.
Re: good thing to remember
Posted: Sat Aug 24, 2002 4:41 am
by Takuma
conthox wrote:A good thing to remember is to always do a end tag for your code, nomatter if it is a PHP or JavaScript or HTML or something else.
In the future, the XHTML and XML langugage maybe is the thing - and it demands stop-tags.
True True True.....
Posted: Sat Aug 24, 2002 4:14 pm
by gotDNS
I agree with conthox...it's always a good idea to end them...I mean, y not? Plus, be neat...so also, if u ever want to make changes later, u dont spend hours looking through confusing code to find somethings...
Be a neat freak...be smiled upon.
Posted: Mon Aug 26, 2002 8:47 am
by nielsene
OK I've been a good boy and closed all those missing tags on my dev tree. I hadn't thought of considering it in an xml context, probably because all my files are simply bracketed in the php tags, without switching in and out of html/php mode. Thanks for all the comments.