在wordpress中检查特定变量是否有值

时间:2012-09-12 07:55:45

标签: php wordpress

我想在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 } ?>

1 个答案:

答案 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 } ?>