PHP: lolwut?

— Barry on February 1, 2008 at 7:19 pm

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 »

  1. <3 ur variable naming schema.

    I’ll have to implement that in my next project, along with more testo.

    Comment by George — February 12, 2008 @ 1:14 am

RSS feed for comments on this post.

Leave a comment

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. | chenb•log