Re: Getting static member for a class which name is stored in a variable

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

 



Francisco M. Marzoa Alonso wrote:
I've code like follows:

<?php

class TestClass {
   public static $Data = 'This is the data';
}

$Obj = new TestClass ();
$ClassName = get_class ($Obj);
echo $ClassName::$Data;

?>

http://www.php.net/manual/en/language.oop5.reflection.php

<?php

class TestClass {
   public static $Data = 'This is the data';
}
$obj = new TestClass;
$a = new ReflectionClass('TestClass');
echo $a->getProperty('Data')->getValue($obj);
?>

in PHP 5.1 this should work

<?php

class TestClass {
   public static $Data = 'This is the data';
}
$a = new ReflectionClass('TestClass');
echo $a->getProperty('Data')->getValue(null);
?>

Greg

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