In PHP, make sure you capture all your Exceptions in the __destruct method, or you will get a very cryptic error message.
Archive for coding
PHP array_shift pass-by-reference
If $list is an Array of references, and you wish to “shift” off the first reference, you cannot simply do
$obj = array_shift( $list );
it will return by value $obj.
The roundabout way of doing it is:
$obj = &$list[0];
array_shift( $list ) ;
or alternately,
reset($list);
$obj = &$list[ key($list) ];
array_shift( $list );
The same goes for array_pop, just reverse the logic for the end of the Array.