我想在div之前检查变量值,以便if变量为空时隐藏if条件中的div,反之亦然。
e.g:
<?php $var=has_post_thumbnail();
if(!empty($var)){ ?>
<div>//some code that is shown only if var has some value</div>
<?php } ?>
答案 0 :(得分:0)
<?php if(isset($var)) // or check for empty if you want that way{ ?>
<div> yes variable is set </div>
<?php } else { ?>
<div> variable not set division </div>
<?php } ?>