if statement - php if, and, or : multiple variables to check. Working, but getting variable not defined errors -
basically i'm trying check if variable exists, if so, run snippet regardless if others exist or not.
i'm using:
if ($a1 || $a2 || $a3 || $a4): $a = "success"; endif;
if $a4
exists, works , set's $a
variable fine. however, i'm getting variable not defined error's before $a4
.
a different variable set if $a0
variable doesn't exist (null):
if (!empty($a0) && $a1 || $a2 || $a3 || $a4) : $a-alt = "no0success"; endif;
this code working fine. however, it's giving me variable not defined error.
make use of isset function, try this
if( isset($variable) ){ // , so.... }else { // define variable $variable = 'foo'; }
Comments
Post a Comment