Reflection in PHP

In computer science, reflection allows object classes to be manipulated, introspect its behavior and structure at run time.

Reflection in PHP provides the useful functionality to examine classes, interfaces, properties, and methods. PHP provides a large number inbuild functions that can be used to accomplish the task.

How to use Reflection
Reflection constructors take the name of the class or function.

$myreflector = new ReflectionClass('ClassName');
$reflectorMethod = new ReflectionFunction('FunctionName');
$method = $myreflector->getMethod(‘find’);
$parameters1 = $method->getParameters();
$parameters2 = $reflectorMethod->getParameters();

PH reflection API offers ways to retrieve doc comments for functions, classes and methods.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.