Trick to create string with HTML tags in PHP

If you are too lazy to perform stripping any kind of  ‘forbidden’ tags in string, like ‘<?’ or ‘ ” ‘ symbol, this is a method:

Example:

<?

$str = <<<EOD
<html><body>
<p>Welcome! Today is the <?php echo(date(‘jS’)); ?> of <?= date(‘F’); ?>.</p>
</body></html>
Text “outside” of the HTML block.
EOD;

echo $str;

?>

It gonna makes your job faster, right? ;)

Leave a Reply