The basic concept:
<?php (conditional php statement) : ?>
<p>some html content</p>
<?php endConditional; ?>
<p>some html content</p>
<?php endConditional; ?>
In the example above the HTML markup will only be output to the browser if the conditional statement resolves to true. Below we'll check that the $data has a valid value ( not equal to "" ), before printing it to the screen.
<?php if($data->user != "") : ?>
<p>Welcome, <?php print $data->user; ?>!</p>
<?php endif; ?>
<p>Welcome, <?php print $data->user; ?>!</p>
<?php endif; ?>
If all goes well, the result will be: Welcome, User!
If not, nothing is output.
No comments:
Post a Comment