Inline Over Echo
Jason Lotito on 2001 March 30
Jason Lotito on 2001 March 30
A quick overview of echo, and how and why you should try and use inline HTML instead of outputting with echo. Just something real quick and easy that I think is rather important
.A quick overview of echo, and how it compares to coding your HTML as Inline. Test results have shown that inline display is 2 times faster than echo.
echo - 0.063347 secs
inline - 0.035276 secs
For example:
<?php
if ($yes != "yes") {
echo "Yes is not Yes";
}
?>
If you compare that to this:
<?php
if ($yes != "yes") {
?>
Yes is not Yes
<?php
}
?>
While this may not be immediately noticeable in small programs, if the program is large, or it starts to recieve a lot of hits, than you will appreciate the little extra speed that inline prints give you. Sure, it requires a bit of extra work on your part, but it does make for nicer programming.
Also, if you think about it, its much easier to use inline than echo'ing everything you do. No more escaping the " in the HTML in the echo's. And you should use the " even if you plan on using echo, as its good form.
