Php overload (2 ). Php overload (2) next to the overload mentioned last time. let's take a look at the overload in php and the method overload. if there is a definition of the overload, refer to: Reload in php (1) thank you for this article. php overload (2)
Next, let's take a look at the reloads mentioned last time in php and the methods. if you have a definition of reloads, refer to: reloads in php (1). thank you. as a beginner, do not spray:
There are two methods.
_ Call: This magic method is automatically executed when you call a method for an inaccessible object! (Object call)
Two typical processing methods:
1. give a friendly prompt!
2. perform the default operation!
_ Callstatic: this magic method is automatically executed when an inaccessible static method is called!
Code details:
Class Student {
Public $ name = 'php ';
Public $ age = 10;
Public function sayName (){
Return $ this-> name;
}
/**
* @ Param $ method_name string method name
* @ Param $ parameters included in the method_arguments array call
*/
Public function _ call ($ method_name, $ method_arguments ){
Echo'
Sorry, the method you called Does Not Exist !, You should call the (***) method! ';
$ This-> defaultAction (); // executes the default method and can be used for redirection to implement redirect.
}
Public function defaultAction (){
Echo'
Here is the default action! ';
}
Public static function _ callStatic ($ m_name, $ m_args ){
Echo 'here is a static method overload! ';
}
}
Student: sayCounter ();
The above is an example for reference during the learning process. let's take a look at it. if you have any questions, we can discuss it.
Rewrite overload (2) next to the overload mentioned last time. let's take a look at the overloading of methods in php. if there is a definition of overloading, refer to: Reload in php (1, thank you. as...