是的,可以在 PHP 的帮助下将 HTML 嵌入 “if” 语句中。以下是一些方法。
<?php if($condition): ?>
it is displayed iff $condition is met
<?php endif; ?>
<?php if($condition): ?>
it is displayed iff $condition is met
<?php elseif($another_condition): ?>
HTML TAG HERE
<?php else: ?>
HTML TAG HERE
<?php endif; ?>
<?php
if ( $condition met ) {
?>
HTML TAG HERE
<?php
}
?>