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 } ?> Code (markup): Notice the brackets in the PHP tags - I have never seen this before - is this a valid method of outputting HTML?
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.
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.