| 
	
 | 
 Posted by Steve on 09/17/07 16:58 
"Yarco" <yarco.w@gmail.com> wrote in message  
news:1190046968.950571.58500@50g2000hsm.googlegroups.com... 
> You are talking something related to pure OO. 
> In my eyes, php4 just look like c, and php5 look like c++. And i like c 
> ++. Because no strict rule said you did it right or wrong. 
> OO is designed to prevent access to the private members, but not 
> saying we don't need to access that in sometimes. That's why c++ need 
> friend class/function i think. 
> If reflection is only a way to discover the public members, it could 
> be designed as a php class(in phplib or zend framework). 
> So it should do something that you can't use php function to do in 
> that it is done in c.(That is accessing private members.) 
 
ummm...php 3 (which has oop capabilities too) and php 5 are cosmetically  
*identicle*...they both look like a scripting language resembling c (like a  
lot other scripting languages). anyway... 
 
the ONLY time reflection allows you to change a private member of a class  
object is when the caller is within appropriate scope...i.e. friend or  
subordinate/nested class. outside of that, reflection NEVER acts as you  
intend, even in c++. jerry is correct. and, as php doesn't support friend or  
nested classes, you are sol. sorry. you are limited to hacking to get values  
of variables that are private...this leaves out, entirely, the possibility  
of discovering 'hidden' interfaces/methods that should remain  
encapsulated...i.e. private. the only other hack i haven't tried is to  
inherit from the object you're trying to hack and then reflecting on the  
base object from there. that may be your workaround for those interfaces. 
 
btw, what are you trying to accomplish?
 
  
Navigation:
[Reply to this message] 
 |