What is the _ call () magic method? _ Call is one of the magic methods. when the program calls a method that is not declared in the current class or has no permission to call, it will call the _ call method. The _ call () method contains two parameters: method name and method parameter. The method parameters exist in arrays. The following is a simple example for your understanding:
What is the _ call () magic method?
_ Call is one of the magic methods. when the program calls a method that is not declared in the current class or has no permission to call, it will call the _ call method. The _ call () method contains two parameters: method name and method parameter. The method parameters exist in arrays.
The following is a simple example for your understanding:
'; Echo' method name: '. $ name; echo'
The '; echo' parameter is:'; Var_dump ($ arguments) ;}}$ sport = new Sport (); $ sport-> run (); echo'
'; $ Sport-> football ('Beckham', 30 );
We create a class and create a run method and magic method _ call () in the class (). Next, we instantiate the object $ sport to call two methods, one is the run () method in the class, and the other is the football () method that does not exist. You can run the code to view the results.
The above is the details of the magic method _ call () instance (php object oriented advanced tutorial). For more information, see other related articles in the first PHP community!