PHP: lolwut?
While I was helping out on a project, I noticed something that’s just so…PHP.
>> class O { var $u; }
>> $f = new O();
O::__set_state(array(
'u' => NULL,
))
>> $f->u = array('c'=>'k');
array (
'c' => 'k',
)
>> empty($f->u->c);
false
Gah! If you are new to the project and combing code to debug something, that’s difficult to notice when $f->u->c is only used in empty() calls within a bunch of if statements. However, PHP does throw a “trying to get property of non-object” notice if you try to access the non-existent value.
1 Comment »
RSS feed for comments on this post.
<3 ur variable naming schema.
I’ll have to implement that in my next project, along with more testo.