It's something else completely.
The error you get means exactly what it says:
The variable was not 'defined' which means it did not get any value assigned to it before it got to this particular line in the script.
A var that did not have a value assigned to it can theoretically take ANY value.
That means that you should NOT trust the outcome of your IF statement.
Allways check if a var is set before you use it for the first time:
if (isset($var))
{
// Variable has been used before, it's safe to use
if ($var == 2)
{
// do something
};
}
else
{
// The var has not been used before!
$var = 1;
};