lundi 1 juin 2015

php if, and, or : multiple variables to check. Working, but getting variable not defined errors

Basically.. I'm trying to check if any variable exists, if so, then run the snippet regardless if the others exist or not.

I'm using:

if ($a1 || $a2 || $a3 || $a4):
$a = "success";
endif;

If only $a4 exists, this works and set's the $a variable fine. However, I'm getting variable not defined error's for anything before $a4.

A different variable is set if the $a0 variable doesn't exist (NULL):

if (!empty($a0) && $a1 || $a2 || $a3 || $a4) :
$a-alt = "no0success";
endif;

This code is working fine. However, it's giving me the variable not defined error. Anyone can help? :)

Aucun commentaire:

Enregistrer un commentaire