This article analyzes the usage of PHP magic function __call() with examples. Share it with everyone for your reference. The details are as follows:
Introduction to the PHP magic function __call(), you will understand it after reading the following example:
<?php class A{ public $name; function test1($a){ echo "test1111"; } function test2($a){ echo "test2222"; } //当某个对象调用某个方法,而当该方法不存在时,则系统会自动调用__call() function __call($method,$val){ echo "类中找不到方法:".$method; } } $aaa = new A(); $aaa ->test(1); ?>
Output result:
Method not found inclass: test
I hope this article will be helpful to everyone’s PHP programming design.