doudi2833 2014-12-02 10:11
浏览 132
已采纳

如果一个或多个变量不为空,则显示html

I want to echo some html if a variable isn't empy, for this I know I can do the following:

if (!empty($test)) {
?>
    <p>Some nice html can go here</p> 
<?php
} 
else 
{ 
echo "It's empty...";
}

How can I do this for several variables? So if one of the variables are not empty then echo the html? Would this do it?

if (!empty($test || $image || $anothervar)) {
?>
    <p>Some nice html can go here</p> 
<?php
} 
else 
{ 
echo "It's empty...";
}
  • 写回答

5条回答 默认 最新

  • drbi19093 2014-12-02 10:13
    关注

    Just try with:

    if (!empty($test) || !empty($image) || !empty($anothervar)) {
      // ...
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?