Archive for coding

PHP Fatal error: Exception thrown without a stack frame in Unknown on line 0

In PHP, make sure you capture all your Exceptions in the __destruct method, or you will get a very cryptic error message.

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 = &$listkey($list) ];
array_shift$list );


The same goes for array_pop, just reverse the logic for the end of the Array.