How can I check for a null varible in PHP?
John
Do PHP varaibles have such a state?
You check to see if a variable is defined by using isset() and you can check to see if a variable contains anything by using empty()
http://php.net/isset http://php.net/empty
...or if you are talking about the SQL to a DB, you can't use: SELECT * FROM myTable WHERE myField=null
Instead, you have to use the syntax as: SELECT * FROM myTable WHERE myField IS null
-- Rich
Originally posted by john8675309 How can I check for a null varible in PHP? John
Use is_null().
Cool, I didn't realise PHP actually allowed you to do that or set a variable back to NULL.
Now just need to find a reason for using it 🙂
I also check for (trim($var)=="")
Originally posted by waygood I also check for (trim($var)=="")
Except that "\t\t\t" != null. And trim("\t\t\t")!="\t\t\t".