NYCPHP Meetup

[nycphp-talk] Need help understanding NULL

Hans Zaunere lists at zaunere.com
Sun Aug 30 00:02:30 EDT 2009


> I don't usually use NULL values for anything because no matter how much
> I read I can't figure out the purpose of it. So far this hasn't been a
> problem for me, but I figure it's going to trip me up sooner or later.

NULL is just a type - a type that can only ever be one thing - NULL

> I've read the NULL sections of the PHP & MySQL manuals and even tried
> googling for articles, but the concept of a “a missing unknown value”
> makes my brain hurt. Can someone please, please, please attempt to
> explain--in the simplest terms possible--what the practical
> advantages/disadvantages of using it might be?

NULL comes from pointers, largely where there can be null references or pointers.  It's an address that doesn't point anywhere, but is some way pointed to and acknowledged, thus it's not purely non-existent (yes, we could argue for years on the subtle meanings of NULL, void, undefined, etc. :)

As always, there's only one real resource these days:

http://en.wikipedia.org/wiki/Null

To me, pragmatically, NULL really only comes down to one thing - it's a special type that always has a single value.  Different languages and environments then utilize this type differently, and add their own meanings.  Thus you need to read the different environment's docs to learn how NULL is treated specifically in that environment, and how it affects getting things down in that environment.  There is no "global" real meaning of NULL - it's language specific.

Other than that NULL is meaningless - it's NULL :)

H




More information about the talk mailing list