I was wondering, mostly because I think I've seen it before somewhere, if it is possible to store HTML within a variable, something like the following (I know this makes no sense, it's just to clarify my question):
<? $var = ' ?>
text goes here
<? '; ?>
And then $var
would equal text goes here
You could do that using output buffering. Have a look at the examples at ob_get_contents() and ob_start().
<? ob_start(); ?>
All kinds of stuff, maybe some <?= "php"; ?> etc.
<? $var = ob_get_contents(); ?>
You may be thinking of the Heredoc syntax:
<?php
$var = <<<EOD
text goes here
EOD;
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With