On Sep 16, 2015, at 06:54, Rowan Collins <rowan.coll...@gmail.com> wrote:
> 
> I want to pull this out for a bit more attention: one of the crucial 
> questions in this thread is whether the language is wrong, or just the 
> documentation. There's one particularly wonky passage someone found in the 
> manual that makes it sound like unitialised variables have an intrinsic type 
> when accessed, rather than just referring the reader to the rules on casting 
> null to any given type; when I have time, I will find and reword it.


The docs suggest that uninitialized variables are null, and the above makes it 
sound like that’s what you’re stating, too. But they’re not: they don’t exist 
at all, they’re uninitialized. If they were null, then PHP wouldn’t spit out 
errors about undefined variable accesses because it would see them as the same 
thing as a (perfectly legal) null variable access. Differentiating these 
various cases is currently a little wonky, requiring some extra boilerplate 
code and/or ugly-ish workarounds (like calling get_defined_vars()). I don’t 
think it’s a huge gap in the language, but it’s a definite gap, and it’s one 
that many less-experienced programmers fall right into with safety checks.

-Bob

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to