PHP: call to an instance method via ClassName::method syntax, results in a static call?

后端 未结 2 1131
暖寄归人
暖寄归人 2021-01-15 22:05

Her is my code:

class MyClass 
{
   public $prop;
   public function method ()
   {
     echo $this->prop;
   }
}

Then somewhere in the

2条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-15 22:27

    Calling non-static methods statically generates an E_STRICT level warning.

    http://php.net/manual/en/language.oop5.static.php

    I suppose you have E_STRICT warnings suppressed. It works (likely for legacy reasons), but it's not recommended.

提交回复
热议问题