Re: Only see class member variables, not parent class member variables

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

 



Peter Lauri wrote:
> Hi,
> 
> I have a class B that extends A. When I do print_r($object_b) it outputs all
> member variables from A and B. I just want to see the variables from B
> excluding the one that B inherits from A, how can I do that? This is just
> for development; I will of course need to use the variables from A to
> actually use the object B.

the short answer is you can't.

the longer answer is you can but writing the code that will extract this info
is probably gonig to taking alot more time than it's worth.

btw you didn't mention what version of php you're using
but here is some php5 code that relates to your problem:


class One { public $one = 1; protected $_one = 1; function myprops() {return get_object_vars($this);} }
class Two extends One { public $two = 2; protected $_two = 2; }
$t = new Two; $o = new One;
var_dump($t, (array)$t, get_object_vars($t), $t->myprops(), $o->myprops(), get_class_vars("Two"));

also read this page for more info:
http://php.net/manual/en/function.get-class-vars.php

> 
> Best regards,
> Peter Lauri
> 

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