简体   繁体   中英

Is the PHP ReflectionClass a singleton?

I have a need to get the ReflectionClass instance of a class from a few different places in my code. I was going to manage a singleton instance of it myself for performance reasons. However, I thought PHP may already do this.

If you new up a ReflectionClass for the same class multiple times, does PHP manage the singleton for you or do any other kind of caching?

No, reflectionClass is not a singleton; nor does it have any intelligence "built in" to act as a singleton if you try to instantiate multiple reflectionClass instances for the same class/object. Each instance of reflectionClass is totally autonomous

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM