You are viewing...

So I ran into this PHP issue with Static variables

Updated on February 27, 2013 at the 23th hour
Posted under:

DISCLAIMER: All views are considered my own and you should not draw any conclusions on associates.

http://stackoverflow.com/questions/3169993/overriding-static-members-in-derived-classes-in-php?rq=1

The above link has a great example of what I want trying to do. I was trying to assign static variables in a subclass that inherited it's static variables from a base and turns out that doing that changed the static variables inside of the base, which is a huge problem for what I was doing. There are many classes that inherit from this one base class, so one screw up like that and things go awry everywhere.

The problem is that static variables are inherited as a reference and to solve this issue you need to re-declare the variables in the class with the assignment.
You just read "So I ran into this PHP issue with Static variables". Please share if you liked it!
You can read more recent posts here.