Should one use PHP to print all of a page's HTML?

Posted by Mala on Stack Overflow See other posts from Stack Overflow or by Mala
Published on 2009-11-20T22:04:26Z Indexed on 2010/05/27 17:11 UTC
Read the original article Hit count: 293

Filed under:
|
|

Hi

So I've always developed PHP pages like this: <?php goes at the top, ?> goes at the bottom, and all the HTML gets either print()ed or echo()ed out. Is that slower than having non-dynamic html outputted outside of <?php ?> tags? I can't seem to find any info about this.

Thanks!
--Mala

UPDATE: the consesus seems to be on doing it my old way being hard to read. This is not the case if you break your strings up line by line as in:

print("\n".
"first line goes here\n".
"second line goes here\n".
"third line");

etc. It actually makes it a lot easier to read than having html outside of php structures, as this way everything is properly indented. That being said, it involves a lot of string concatenation.

© Stack Overflow or respective owner

Related posts about php

Related posts about html