Re: Object to array conversion oddity

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

 



Here's a more accurate example:

<?php
class Myclass {
        public $field1 = '';
        private $field2 = '';
        protected $field3 = '';
}

$myclass = new Myclass;

var_dump($myclass);
var_dump((array)$myclass);
?>

This produces:

object(Myclass)#1 (3) {
  ["field1"]=>
  string(0) ""
  ["field2:private"]=>
  string(0) ""
  ["field3:protected"]=>
  string(0) ""
}
array(3) {
  ["field1"]=>
  string(0) ""
  ["Myclassfield2"]=>
  string(0) ""
  ["*field3"]=>
  string(0) ""
}

So it seems protected fields behave differently too.

Marcus
--
Marcus Bointon
Synchromedia Limited: Creators of http://www.smartmessages.net/
marcus@xxxxxxxxxxxxxxxxxx | http://www.synchromedia.co.uk/

--
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