I have a PHP function that I’m using to output a standard block of HTML. It currently looks like this:
<?php function TestBlockHTML ($replStr) { ?> <html> <body><h1> <?php echo ($replStr) ?> </h1> </html> <?php } ?>
I want to return (rather than echo) the HTML inside the function. Is there any way to do this without building up the HTML (above) in a string?
You can use a heredoc, which supports variable interpolation, making it look fairly neat:
Pay close attention to the warning in the manual though – the closing line must not contain any whitespace, so can’t be indented.