So I've got a question about coding style. In many examples around the Interweb I've seen people flopping back and forth between breaking in and out of PHP in their HTML code to display their data, or having PHP spew out all of the necessary HTML.
vs
Then there's heredoc, which I hear is memory intensive and generally shouldn't be used.
So after all of that, here's my boggle. What's the Right Way To Do It(tm)? I must admit, if left to my own devices, I use heredoc. But if that's not an option, I choose to have PHP spew out everything. Breaking in and out of PHP looks ugly and is more difficult to read in vim or NetBeans due to the lack of proper color coding. Or am I fretting too much about this? Are they all valid life choices as long as I pick one and stick with it?
Code:
<html>
<body>
<h1>Stuff!</h1>
<p>Now I'm going to do some PHP to fill in the blanks! <?php echo $somevariables; ?> Wasn't that fun?</p>
</body>
</html>
vs
Code:
<?php
echo "<html>
<body>
<h1>Stuff!</h1>
<p>Now I'm going to do some PHP to fill in the blanks!" . $somevariables . "Wasn't that fun?</p>
</body>
</html>
";
?>
Then there's heredoc, which I hear is memory intensive and generally shouldn't be used.
Code:
<?php
echo <<<HTML
<html>
<body>
<h1>Stuff!</h1>
<p>Now I'm going to do some PHP to fill in the blanks! {$somevariable} Wasn't that fun?</p>
</body>
</html>
HTML;
?>
So after all of that, here's my boggle. What's the Right Way To Do It(tm)? I must admit, if left to my own devices, I use heredoc. But if that's not an option, I choose to have PHP spew out everything. Breaking in and out of PHP looks ugly and is more difficult to read in vim or NetBeans due to the lack of proper color coding. Or am I fretting too much about this? Are they all valid life choices as long as I pick one and stick with it?