Static methods can be invoked in a non-static method of PHP
Class test{public
static function Strprint () {
echo ' This is strprint static function<br> ';
}
Public Function Staticfuncinvoke () {
self::strprint ();
}
}
$test = new test ();
$test->staticfuncinvoke ();
The above code outputs: This is strprint the static function.
And the following code will be hung directly, PHP directly gives the fatal error:
Fatal error:using $this When isn't in the object context into E:\htdocs\test\content.php on line 6
Class test{public
static function Strprint () {
$this->staticfuncinvoke ();
}
Public Function Staticfuncinvoke () {
echo ' This is a nonstatic function named Staticfuncinvoke ';
}
}
Test::strprint ();
The above is small series for everyone to talk about static and Non-static methods in PHP all the content of the mutual call, I hope that we support the cloud-Habitat Community ~