PHP can use static calls or PHP reflection to call methods without instantiation. That is to say, when class members are defined as private, they can also be accessed externally, that is, the class can be accessed without creating an instance of the class. members and methods.
PHP does not instantiate the calling method
Static calling, using PHP reflection.
Related introduction:
PHP reflection mechanism
Introduction
Even if a class member is defined as private, it can be accessed externally without creating an instance of the class. Can access class members and methods.
PHP has added a reflection mechanism since version 5.0. It provides a set of powerful reflection APIs, allowing you to access and use classes, methods, properties, parameters, annotations, etc. in the PHP running environment. Its functions It is very powerful and is often used in highly extensible PHP frameworks to automatically load plug-ins, automatically generate documents, and can even be used to extend the PHP language. Since it is a built-in oop extension of PHP and a feature of the language itself, it can be used without adding additional extensions or configurations.
For more related knowledge, please visit PHP Chinese website!
The above is the detailed content of How to call method in php without instantiation. For more information, please follow other related articles on the PHP Chinese website!