Home > Article > Backend Development > Detailed graphic explanation of php's reflection API
PHP5 adds a new feature: Reflection. This feature enables PHP to reverse-engineer class, interface, function, method and extension. Through the PHP code, you can get all the information of a object and interact with it.
PHP's reflection API, that is, when PHP is running, by analyzing the PHP program, the class, method, attributes, parameters and other information to which the object belongs can be derived.
How to use reflection API
Sample code Person.php
##The ReflectionClass class reports information about a class
The output result is: name say set get
You can also use the class function to obtain the information associated with the object attributes
array
Get class information through the class() function
Print results:
Through this reflection API, you can do Hook implements plug-in functions, dynamic proxy, etc.
Examples of dynamic agents found online
The above is the detailed content of Detailed graphic explanation of php's reflection API. For more information, please follow other related articles on the PHP Chinese website!