0
class A{
   function a(){
     
   }
}

class B extends A{
   static function b(){
      parent::a();      /* this gave me a php warning: a() should not be called statically */ 
     
   }
}

Any Comment?

Note: I know that become class A in static will be fix the issue, but I don't want to.

Peter Duniho
  • 68,759
  • 7
  • 102
  • 136
Alejandro
  • 3
  • 1
  • 2
    _"but I don't want to"_ is not a valid reason to not comply with a programming language's requirements. In the code above, `A::a()` is a non-static method, so what is `$this` supposed to refer to if you call `a()`? How is `a()` supposed to refer to non-static members of `A`, if you call `a()` statically, without a `$this` reference for the method to use? If you really want to call `a()` from `b()`, then either make `a()` a static method, or make `b()` a non-static method, just like the duplicates say. – Peter Duniho Jul 03 '21 at 05:46
  • 1
    Does this answer your question? [Non-static method … should not be called statically](https://stackoverflow.com/questions/19693946/non-static-method-should-not-be-called-statically) – Peter Duniho Jul 03 '21 at 05:47

0 Answers0