Question Details

No question body available.

Tags

php class oop inheritance

Answers (4)

June 5, 2026 Score: 1 Rep: 17,604 Quality: Low Completeness: 70%

I simplified your non-working example to: https://3v4l.org/P8qJH#v8.5.7

I get your error.

Then when I turn the definition of the classes around: https://3v4l.org/oeZ33#v8.5.7

There is no error.

My conclusion is that when you extend class A, and name it class B, that class A should be defined before class B.

This is only true when you actually want to instantiate such a class.

June 5, 2026 Score: 0 Rep: 57,323 Quality: Low Completeness: 0%

One issue being that in the case where it fails it still executes the first echo.

June 5, 2026 Score: 0 Rep: 17,604 Quality: Low Completeness: 0%

Yes, I found that out as well, and changed the reply accordingly. The two phases idea was flawed.

June 6, 2026 Score: 0 Rep: 20,110 Quality: Low Completeness: 20%