Then the last said overload, we understand the next overload in PHP, the method of overloading, if there is a pipe overload definition, reference: PHP overload (i) This article, thank you. As a beginner, Daniel, don't spray:
Basically, two methods.
__call, the Magic method is automatically executed when a method is invoked on an object that is not accessible! (Object invocation)
Typical two ways of handling:
1, give a friendly hint!
2, perform the default action!
__callstatic, the Magic method is automatically executed when an inaccessible static method is invoked!
Detailed code:
Class Student {
Public $name = ' php ';
Public $age = 10;
Public Function Sayname () {
return $this->name;
}
/**
* @param $method _name String method name
* @param $method parameters to be carried when _arguments array calls
*/
Public Function __call ($method _name, $method _arguments) {
Echo '
Sorry, you call the method does not exist!, you should call (* * *) Method! ';
$this->defaultaction ();//Execute the default method, you can do the jump switch, realize redirect
}
Public Function DefaultAction () {
Echo '
This is the default action! ';
}
public static function __callstatic ($m _name, $m _args) {
Echo ' Here is the static method overload! ';
}
}
Student::saycounter ();
The above is the study time reference example, under ... If there are questions, we can discuss