PHP 5 and Strict Standards error
Why I ge开发者_运维问答t this error?:
Strict Standards: Non-static method Hello_Misc::fix_protocol() should not be called statically, assuming $this from incompatible context in test.php on line 834
line 834:
$this->my_url = Hello_Misc::fix_protocol($my, 1);
I am using latest version of PHP (>= 5.1.3) but in previous version (<= 5.1.2) it does work (ref).
The static
keyword is the key! You need to declare the method as static:
class Hello_Misc {
static public function fix_protocol($p1, $p2) {
// code
}
}
However, it you do so (and you should), you must make sure you're not using object context (i.e. $this
) in this method. If you do, you will have to review your design a little.
精彩评论