4
I was doing some tests with value assignments by PHP references and came across a curious example.
$a->b->c->d->e->f->g->h->i->j =& $null;
Both the variables $a
and Null
do not exist in any scope of my script.
When I give a print_r($a)
, see what is returned:
stdClass Object
(
[b] => stdClass Object
(
[c] => stdClass Object
(
[d] => stdClass Object
(
[e] => stdClass Object
(
[f] => stdClass Object
(
[g] => stdClass Object
(
[h] => stdClass Object
(
[i] => stdClass Object
(
[j] =>
)
)
)
)
)
)
)
)
)
The weird thing is, when I try to do this without reference, look what happens:
$a->b->c = 1;
PHP Warning: Creating default Object from Empty value on line 1
Why does this happen in PHP? What is the reason for this behavior (the object being created out of thin air and not issuing any Warning)?
Why variables $a
and $null
did not return Undefined variable
when I used references?
Just missing the image of Ryu giving a hadouken in the result of
array
– Wallace Maxters
@Brunocosta worse than it is, there is an explanation. I’m just waiting for someone who explains better than what I already know
– Wallace Maxters
You guys, nobody’s taking a chance on answering that?
– Wallace Maxters