PHP magic __call method

Lesson 3: PHP Magic Methods

Today we're going to dive into one of my favorite Php magic methods, the Php __call Magic method.


Imagine being able to call any method with any number of parameters on an instance of a class...


Well guess what, you can! 

Magic __call method parameters

The PHP magic __call method accepts two arguments.



Another way to think about $method is like this: 

$building->$method($parameters)



Another way to think about $parameters is like this: 

$building->$method($parameters)



Together you can think about the magic __call method like this.

In this Clean Code Studio screencast we'll use the magic call method to dynamically call and execute PHP functions at run time as well as access private, normally inaccessible, private methods on a PHP class .