Air Jordans - Skype - Debt Consolidation - Debt Consolidation - Find jobs

PDA

View Full Version : Php Html Output


Omzy
Oct 28th 2008, 8:33 am
I use echo statements to output my HTML code in PHP, however I came across this piece of code:


<?php if ($_POST['Submit'] == "Submit" && !$allvalid) { ?>
<div id="downloadbar" class="bad">
Please check the fields highlighted in red in order to proceed.
</div>
<?php } ?>


Notice the brackets in the PHP tags - I have never seen this before - is this a valid method of outputting HTML?

unski84
Oct 28th 2008, 8:39 am
Yes, at least I am using this method all the time :)

osmasters
Oct 28th 2008, 8:44 am
Yes, this is correct method and this is good to have for program where you want to write too many html codes in if or else condition.

Omzy
Oct 28th 2008, 9:02 am
So no need to do echo ' or echo " and have 2 worry about the quotation signs or escaping characters

markowe
Oct 28th 2008, 9:08 am
Yes, I just realised this recently :)

Bear in mind that the HTML that's outside the php tags will be subject to the conditional statements INSIDE - make sense?

I can't help feeling this is messy from a "good practice" point of view - probably the purists don't like this kind of chopping and changing from PHP to HTML output and back.