Forum Moderators: coopster

Message Too Old, No Replies

Question about php code layout

         

supermanjnk

3:12 pm on Jul 15, 2004 (gmt 0)

10+ Year Member



I was wondering, when you are putting html/javascript into your php code, Is it better to use

echo" html/javascript code";

or is it better to have like

<?
if blah blah blah blah {
?>
Html/javascropt code
<? }
else {
more php code
?>

or is it better to use an include statement and have it in a seperated doc

Timotheos

4:05 pm on Jul 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think it really just comes down to personal preference. So I go with your second example. If there's a lot of html/javascript then I get out of php. To my mind it looks cleaner and I don't have to worry about escaping all those special characters.

jatar_k

4:14 pm on Jul 15, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



ergophobe did some good work on this topic
Benchmarking PHP text output [webmasterworld.com]