Lester Caine wrote on 18/09/2015 16:17:
You don't do much real database coding do you ...
NULL is returned for fields that have no entry on a secondary table, so
the result set NATURALLY returns NULL.
Why do you keep going on about null? We're talking about non-existent
variables, not null!
We have been living with the fact
that PHP barf's when trying to check for NULL for a long time.
OK, now you've lost me. I can check for NULLs just fine, using is_null()
if I know the variable exists (which I pretty much always do) or isset()
if it might not. No barfing necessary.
There are a number of ways those variables can be generated and switching off
the
notices is currently the only way.
The only way to do what? If you have a variable which is either null or
non-existent, and you don't care which, use isset(). That's literally
the same as turning off notices and then using is_null().
exists() has a place in SOME coding
styles which does not require to find the 'NULL' some other way to avoid
the potential notice!
exists() would not be a way of avoiding the notice. exists() would be a
way of distinguishing an extra state, quite separate from null.
If what you want to write is "if ( ! exists($foo) || is_null($foo) ) {
... }" then that is exactly what "if ( isset($foo) )" will give you,
without any notices whatsoever.
Regards,
--
Rowan Collins
[IMSoP]
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php