PHP magic function __call() usage example

WBOY
Release: 2016-07-25 08:52:07
Original
981 people have browsed it
  1. class A{
  2. public $name;
  3. function test1($a){
  4. echo "test1111";
  5. }
  6. function test2($a){
  7. echo "test2222";
  8. }
  9. //When an object calls a method and the method does not exist, the system will automatically call __call()
  10. function __call($method,$val){
  11. echo "Method not found in class: ".$method;
  12. }
  13. }
  14. $aaa = new A();
  15. $aaa ->test(1);
  16. ?>
Copy the code

Output result: Method not found in class: test



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template