Reputation: 26556
Mixing html and php is simple:
<? while($row): ?>
<p><?=$row['name'] ?></p>
<?php endwhile; ?>
But how could i store html like this into a php variable? (Purposed syntax, but doesn't work)
<? $html = ?>
<p>My HTML!!</p>
<? ; ?>
Upvotes: 0
Views: 504
Reputation: 655209
You could use the heredoc syntax when declaring the string:
<?php
$html = <<<HTML
<p>My HTML!!</p>
HTML;
?>
This treats anything between the start <<<HTML
(HTML
is the identifier) and the end HTML
as a string. Note that the closing identifier must be the first in a new line without any indention.
Upvotes: 0