You can lay out the PHP and HTML anyway you want. Ultimately its the end result that matters as well as consideration of when headers are pushed.
Output is the last thing I do. Takes more memory, but its easier to modify than simply outputting.
header('HTTP/1.1 420 Enhance Your Calm');