At 2:35 PM -0400 5/14/09, PJ wrote:
I'm a bit fuzzy on the relationship between the <? ?> and the HTML code.
Where should the php code be placed in a page so that execution is
carried out smoothly? So far, my coding has managed to avoid horrendous
snags; but as I delve deeper into the quagmire of coding, I would like
to clear the fog before me.
Perhaps I have been fortunate up to this point... :-)


First, do not use <? ?> -- that's a short tag and it has been depreciated and will not work with xml.

Second, use <?php  ?> instead.

Third, place the php code anywhere you want within the html document (top, bottom, middle, and any where). It makes no difference (other than readability) -- all of it will be executed before the browser see's anything.

Fourth, if you want php to print something along with (inside) the html, simply echo() it, such as:

<?php echo("Hello World"); ?>

and Hello World will be show as a H1 headline.

Please note, the "()" seen in my use of echo is not necessary -- it's just another one of those things that I do that no one else does. It's not wrong, but it serves no purpose other than it looks good and makes sense *to me* YMMV.



PHP General Mailing List (
To unsubscribe, visit:

Reply via email to