jeudi 26 mars 2015

If statement with multiple variables fails but each variables on its own returns true

I have an If statement that was failing [ if($file1 && $file2 && $file3) ] so I decided to test the individual parts of the If statement to see which part was causing the failure but they all passed when tested individually.


Any ideas why this could be?


Example of the code:


These are the ones I was using to test:



if($file1){
echo "File1 Success";
} else {
echo "File1 Fail";
}

if($file2){
echo "File2 Success";
} else {
echo "File2 Fail";
}

if($file3){
echo "File3 Success";
} else {
echo "File3 Fail";
}


This is the actual one that I am trying to figure out why it's failing:



if($file1 && $file2 && $file3){
...do more stuff
} else {
echo "If statement failed";
}


$file1 is a integer used in a database


$file2 is a varchar for who entered it


$file3 is the actual file name


Later on the file name is used for making a path but it fails before it even gets there.


Aucun commentaire:

Enregistrer un commentaire