[nycphp-talk] PHP 5 guru: help fix simple PEAR DB problem
Adam Maccabee Trachtenberg
adam at trachtenberg.com
Mon Feb 2 17:15:07 EST 2004
On Mon, 2 Feb 2004, Daniel Convissor wrote:
> On Mon, Feb 02, 2004 at 09:01:53AM -0500, Adam Maccabee Trachtenberg wrote:
> > I have a backtrace, but it would be nicer to see if we can get this
> > down to a shorter script that doesn't involve lots of includes and
> > database accesses.
>
> Done. I've pared down the PEAR. Still produces weird output, but not the
> same weird output. Also, the output changes if the SQLite file is
> unlinked at the end! Wacky!
Here is the shortest script I can come up with that still causes a
crash:
$array = array(1);
$element = (object) array('a' => 1);
get_object_vars($element);
$array[] = $element;
print_r($array);
It's super subtle, you need to:
1) Use an array with a string key: array('a' => 1)
2) Cast it to an object and call get_object_vars() on the result.
3) Assign this cast object to an array with multiple elements.
4) Call print_r() on the resulting array.
If I remove any of these, the crash goes away. I can generate a
backtrace if you can't reproduce this on your machine.
-adam
--
adam at trachtenberg.com
author of o'reilly's php cookbook
avoid the holiday rush, buy your copy today!
More information about the talk
mailing list