Php if multiple variables exist

So, I have a problem with my PHP running a command if there are multiple variables. I made a simple version for people to see that I'm trying to fix it easier. I thank everyone in advance who can help :)

<?php
if ((isset($finalusername)) && if (isset($finalpassword)) && if (isset($finalemail)))
  echo "This will save.";
?>
+5
source share
4 answers
if (isset($finalusername, $finalpassword, $finalemail))

Also see the Ultimate PHP Guide issetandempty .

+19
source

You do not need to place several in it if.

if (isset($finalusername) && isset($finalpassword) && isset($finalemail)) {
   // ...
}

In fact, I would even do it like that ...

if (isset($finalusername, $finalpassword, $finalemail)) {
   // ...
}
+2
source

, isset() .

, :

if (isset($finalusername, $finalpassword, $finalemail)) {
    echo "This will save.";
}
+1

:

if (isset($var1))
{
    if (isset($var2))
    {
        // continue for each variables...
    }
}
-2

All Articles