It seems like my code works to check for null if I do
if ($tx)
or
if (isset($tx))
why would I do the se
I want to point out that everyone's reponse I've read here should have one caveat added:
"isset() will return FALSE if testing a variable that has been set to NULL" (php.net/isset).
This means that in some cases, like checking for a GET or POST parameter, using isset() is enough to tell if the variable is set (because it will either be a string, or it won't be set). However, in cases where NULL is a possible value for a variable, which is fairly common when you get into objects and more complex applications, isset() leaves you high and dry.
For example (tested with PHP 5.2.6 with Suhosin-Patch 0.9.6.2 (cli) (built: Aug 17 2008 09:05:31)):
outputs:
bool(true)
bool(false)
bool(false)
Thanks, PHP!