PHP magic methods: _ call and _ callStatic usage, __call _ callstatic
Core code
// Magic method _ call/* $ method get method name $ arg get method parameter set */class Human {private function t () {} public function _ call ($ method, $ arg) {echo 'method you want to call that does not exist ', $ method,' method <br/> '; echo 'also passed a parameter <br/>'; echo print_r ($ arg), '<br/>';} public static function _ callStatic ($ method, $ arg) {echo 'You want to call a non-existent ', $ method, 'static method <br/>'; echo 'also transmits a parameter <br/> '; echo print_r ($ arg), '<br/>'; }}$ ha = new Human (); // example1 $ ha-> t (1, 2, 3 ); echo '<br>'; // example2 $ ha-> say ('A', 'B', 'C'); echo '<br> '; // example3 $ ha: run ('D', 'E', 'F ');
You want to call the method t that does not exist.
A parameter is also passed
Array ([0] => 1 [1] => 2 [2] => 3)
You want to call a method that does not exist.
A parameter is also passed
Array ([0] => a [1] => B [2] => c)
You want to call a non-existent run static method
A parameter is also passed
Array ([0] => d [1] => e [2] => f)