如果一个或多个变量不为空,则显示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...";
}

Just try with:

if (!empty($test) || !empty($image) || !empty($anothervar)) {
  // ...
}

You should check every variable:

!empty($test) || !empty($image) || !empty($anothervar)

empty function does not take multiple arguments.

So, you need to user empty separately for each variable.

The final code should be:

if (!empty($test)  || !empty($image) || !empty($anothervar)) {

Just check all the three variables.

Also, I advise you to embed your php into your html to have a better readable document, like this:

<?php if (!empty($test) || !empty($image) || !empty($anothervar)): ?>
    <p>Some nice html can go here</p> 
<?php else: ?>
    It's empty...
<?php endif; ?>

Just another solution:

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

Or if you have a lot of variables to check:

$check = array("test","image","anothervar");
$empty = true;
foreach($check as $var) {
   if(! empty($$var)) {
      $empty = false;
   }
}
if($empty) {
   echo "It's completely empty...";
} else {
?>
    <p>Some nice html can go here</p> 
<?php
}