|
Posted by Steve on 09/13/07 05:41
"Yarco" <yarco.w@gmail.com> wrote in message
news:1189656437.305893.202070@r34g2000hsd.googlegroups.com...
> But when i think of Reflection, it is a method to view everything in
> an object(member's type and value).
> If it doesn't support private member, we already have such functions
> like get_class_XXX...no need reflection.
well, your reflection on Reflection is limited to how oop is supported in
the language you're using. reflection in php is very limited. you can work
around this of course. the only time you can't get the variables and their
respective values is when a class is static and it does not give a means to
get it's instance. otherwise, you can turn the class object's instance into
a string and parse it. this does not give you the ability to do anything to
it's data, but that is not the question at hand.
$object = new Something();
$objectAsString = print_r($object, true);
// code to parse the string version of $object here
// code to do with that information what you will here
php lacks a ton of oop features liked shared interfaces (like a shared
constructor, which is nifty), friend interfaces, nested classes, etc.. maybe
later they'll all be added inclusive of better reflection, but for now
you'll just have to make do.
Navigation:
[Reply to this message]
|