Tuesday, January 10, 2012

Two versions of PHP if statement


There are two versions of PHP if statement when combining PHP and HTML block.
Version 1:
<?php if(<your evaluation here>) { ?>
// HTML code
<?php } else { ?>
// HTML code
<?php }; ?>

Version 2
<?php if(<your evaluation here>): ?>
// HTML code
<?php else: ?>
// code
<?php endif; ?>

Same on “for” and “while” loops as well as “elseif”.

No comments:

Post a Comment