PHP can call non-static methods in static form. This post was last edited by lytreo650 in 2014-03-1410: 05: 21 & lt ;? Phpclass & nbsp; test & nbsp; {public & nbsp; function & nbsp; sayHello & nbsp; () & nbsp; {echo PHP can call non-static methods in static form.
This post was last edited by lytreo650 at 10:05:21
Class test {
Public function sayHello (){
Echo 'hello world ';
}
}
Test: sayHello ();
Run the above code to print out hello world without any error.
However, I read the book "in-depth PHP object-oriented, patterns and practices", which clearly states
A non-static method can be called statically only when the parent keyword is used to call a method.
What is going on here? It is hard to say that PHP does not support this in mind, but it can actually do this?
------ Solution --------------------
It is the practice of php to call a non-static method in the static form.
Only the E_STRICT check is introduced in php 5.3, and php 5.4 enforces the check.
------ Solution --------------------
It is related to the error check level of different php versions.
------ Solution --------------------
That's of course!
You do not have ~ E_STRICT?
Error checks at the E_STRICT level are blocked.