开发者

Can one unset all parent classes when only a child class in known in PHP?

开发者 https://www.devze.com 2023-03-18 02:36 出处:网络
I have extended a class that is part of 开发者_Python百科a large library. I instantiate the extended class.Later, I\'d like to unset() the extended class and all the related classes that have been in

I have extended a class that is part of 开发者_Python百科a large library.

I instantiate the extended class. Later, I'd like to unset() the extended class and all the related classes that have been instantiated in library. How do I do this when I only know the extended class that I have instantiated.


Not quite sure what you want to do. If you have B that has extended A then unsetting A will delete the data in the combined structure of A and B, Since A extends B basiclly ends up beeing a class made up of the code of A + B. But do you prehaps mean that you have some central object handler and whish to do some kind of reference counting?

Explain a bit further and prehaps paste some code and it will be more clear.

For your info, there is the function get_parent_class() that can be used to figure out what class a given class has extended.

But, if you just want to unset B and are afraid that the A portion of B would continue to live on you can relax. Unset unsets the entire object.

0

精彩评论

暂无评论...
验证码 换一张
取 消