PHP static method call problem, ask Daniel to answer
Class Cat {
}
Class Hypnotic_cat extends Cat {
Constructor
function Hypnotic_cat () {
}
This function must is called statically
public static function Hypnotize () {
Echo ("The cat was hypnotized.");
Return
}
}
Hypnotize All Cats
Hypnotic_cat::hypnotize ();
$hypnotic _cat = new Hypnotic_cat ();
Does Nothing
$hypnotic _cat->hypnotize ();
?>
Why is this call or can it be a result? The static method is not only used:: To invoke it?
------Solution--------------------
Who told you not to? Of course you can!
Just what you need to notice is that the static method cannot be used $this
------Solution--------------------
Can be used this way, but detours, is generally hypnotic_cat::hypnotize ();
------Solution--------------------
Citation:
who told you not to? Of course you can!
Just what you need to notice is that the static method cannot be used $this
To add, you'd better not show up in a static method.
As for calling methods, this is very flexible.