Sorry, Straterra but I've got to disagree with your advice.
Straterra wrote:Edit : It is better practice to stay in PHP and merely echo HTML. For an example, if you wanted to do this, you would use this code.
Not necessarily, it really depends on personal choice and need. In many respects the further your HTML is kept from your PHP the better.
Straterra wrote:Just remember, when you echo HTML, you much escape the quotation marks with \ slashes.
Well no, you don't have to it depends how you're echoing the code, personally I wouldn't bother with the hassle of doing:
Code: Select all
echo "<meta http-equiv="refresh" content="".$refreshsec."">";
IMHO, if you put it into single quotes it's easier to maintain and clearer to read:
Code: Select all
echo '<meta http-equiv="refresh" content="'.$refreshsec.'">';
but in heredoc (or HTML outside a PHP block like the original code) it's even easier. In heredoc format you would have something like this:
Code: Select all
echo <<<END
<meta http-equiv="refresh" content="$refreshsec">
END;
no quotes and no concenation, nice.
Mac