Unexpected results with object to array cast

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux