Code: Select all
<p>Some text and tags</p>Code: Select all
<?php echo "<p>Some text and tags</p>?>Moderator: General Moderators
Code: Select all
<p>Some text and tags</p>Code: Select all
<?php echo "<p>Some text and tags</p>?>Actually, in templating you are not supposed to incorporate logic, other than simple if, else, for and foreach loops. So your controller would generate the list using data it retrieves from the model. Then in your template it would look like this:lkjkorn19 wrote:I guess it depends on the context as well. If you're going to generate a list, it would be ridiculous to load up data (in PHP), stop PHP, type that one "<h1>List</h1><ul>" line, get back into PHP and start listing things up.
If you're to do a longer paragraph that explains something (for example), exiting PHP is advised just principally for overview reasons. Like that, you don't have to worry about escaping quotes and whatnot.
Code: Select all
<ul>
<?php foreach ($listItems as $item): ?>
<li><?php echo $item; ?></li>
<?php endforeach; ?>
</ul>