It is my understanding that vars do not have to be declared before use in PHP.
I have a little test script that starts:
<?php $testing; // declare without assigning echo "is null? ".is_null($testing); // checks if null echo "<br/>
Pretty straightforward, or so it seems. The output I get from this is:
Warning: Undefined variable $testing in index.php on line 3
is null? 1
So it executes, but why the error when I first check the variable? It would seem that if I don’t really need to declare then I should not get any error?
One more thing I noticed… I changed the line to read $testing = ‘’; // declare without assigning so now I do not get an error, but I also do not get any output from the is_null so what I get is is null? with nothing behind it…
Can anyone provide any insight into this?
Thanks for reading!