I have some scripts that do some calculations with data coming from a form, and to make the sum of them all I created another file where I make the sum:
include "varios.php";
$total = $var1 + $var2 + $var3; /// etc
However, I want to only add the variables that have been set, so I tried:
$total = isset($var1) + isset($var2) + isset($var3);
But, from what I've noticed, it looks like 1
if set, and 0
if not, regardless of the value coming from the form.
As I was asking this question I have already been able to solve (but I do not know if in the best way), like this:
if (!isset($var1)){
$var1 = 0;
}
So I do not have any more problems, but then I was in doubt because the first form did not work. Doing that way I think I made the variable type boolean ... Is this? How does this occur, and why?