This article describes the reflection in PHP, we do not quite understand the PHP reflection can be seen to understand, this article simply tells the reflection in PHP, nonsense less, let's take a look!
PHP 5 has a complete reflection API that adds the ability to reverse engineer classes, interfaces, functions, methods, and extensions. In addition, the reflection API provides a way to remove document comments from functions, classes, and methods.
Use of reflection in the TP frame
Public reflectionclass::__construct (mixed $argument)
2. reflectionclass::newinstanceargs-creates a new class instance from the parameters given, which is passed to the constructor of the class.
public object Reflectionclass::newinstanceargs ([array $args])
3,/thinkphp/library/think/container.php
/** * Invoke Reflection Execution Class instantiation support Dependency Injection * @access public * @param string $class class name * @param array $ VARs parameter * @return Mixed * /Public Function Invokeclass ($class, $vars = []) { try { $ reflect = new Reflectionclass ($class); $constructor = $reflect->getconstructor (); Injection $args to support dependency = $constructor? $this->bindparams ($constructor, $vars): []; Return $reflect->newinstanceargs ($args); } catch (Reflectionexception $e) { throw new ClassNotFoundException (' Class NOT exists: '. $class, $class); } }