In my previous question I found two solutions for accessing static members. I would like to know which one is the better way, and why.
+1
A:
In my opinion, if your statis members are public, you should access it directly. Otherwise if it's private or protected, you can access via a method. If you use Reflection to access a static member, the PHP interpreter need some unncessary steps to reflect all member of your object and the process is slower. Another reason to avoid using reflection is you can use code completiong of IDE for improving productivity.
coolkid
2010-09-29 04:45:33
in your "Using reflection" link, you have to use reflection because the class name A is dynamic at run time, so there's no other ways for determine its static member name
coolkid
2010-09-29 04:48:39
So you mean using object method is good for me? is that faster even when we have few stuffs in class constructor?
KoolKabin
2010-09-29 06:52:13
static member of a class is a class member, not an instance member. So it doesn't depend on whether we do in constructor
coolkid
2010-09-29 06:57:43