Unexpected results with object to array cast

From: Date: Wed, 03 Nov 2004 11:31:30 +0000
Subject: Unexpected results with object to array cast
Groups: php.general 
Request: Send a blank email to php-general+get-201008@lists.php.net to get a copy of this message
This code: <?php class TestClass { private $self; function __construct () {
       $this->self = $this;
} } $Obj = new TestClass (); print_r ( $Obj ); echo "<br>"; $Arr = (array) $Obj; print_r ( $Arr ); ?> Produce the following output: TestClass Object ( [self:private] => TestClass Object *RECURSION* ) Array ( [ TestClass self] => TestClass Object ( [self:private] => TestClass Object *RECURSION* ) ) While I expect to find for the second line something more similar to: Array ( [self:private] => TestClass Object *RECURSION* ) Can someone explain me what I'm doing wrong? P.S. Die Reischtag Brände

« previous php.general (#201008) next »