I was wondering why php does not complain when we reference a non existing variable (being it a plain variable or array), is this just the way it is, or there is something e
throws no warning about a non existing variable.
This is how references work. $a = &$b;
creates $b
if it does not exist yet, "for future reference", if you will. It's the same as in parameters that are passed by reference. Maybe this looks familiar to you:
preg_match($pattern, $string, $matches);
Here the third parameter is a reference parameter, thus $matches
does not have to exist at time of the method invocation, but it will be created.
that &NULL is something I didn't really expected, I thought I would get a plain NULL.
Why didn't you expect it? $r['er']
is a reference "to/from" $t
. Note that references are not pointers, $r['er']
and $t
are equal references to the same value, there is no direction from one to the other (hence the quotation marks in the last sentence).