PHP if multiple variables exist

Spencer May picture Spencer May · Jan 25, 2012 · Viewed 19.7k times · Source

So i'm having a bit of a problem with having my PHP run a command if multiple variables exist. I made a simple version for people to see what i'm trying to fix easier. Thanks in advance to anyone who can help :)

<?php
if ((isset($finalusername)) && if (isset($finalpassword)) && if (isset($finalemail)))
  echo "This will save.";
?>

Answer

deceze picture deceze · Jan 25, 2012
if (isset($finalusername, $finalpassword, $finalemail))

Also see The Definitive Guide to PHP's isset and empty.