3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyClass { protected function myFunc() { echo "MyClass::myFunc()\n"; } } class OtherClass extends MyClass { // Override parent's definition public function myFunc() { // But still call the parent function parent::myFunc(); echo "OtherClass::myFunc()\n"; } } $class = new OtherClass(); $class::myFunc(); ?>
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught Error: Non-static method OtherClass::myFunc() cannot be called statically in /in/ioZUE:21 Stack trace: #0 {main} thrown in /in/ioZUE on line 21
Process exited with code 255.
Output for 7.0.0 - 7.0.32, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
Deprecated: Non-static method OtherClass::myFunc() should not be called statically in /in/ioZUE on line 21 Deprecated: Non-static method MyClass::myFunc() should not be called statically in /in/ioZUE on line 15 MyClass::myFunc() OtherClass::myFunc()
Output for 7.3.32 - 7.3.33
MyClass::myFunc() OtherClass::myFunc()
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.38
Strict Standards: Non-static method OtherClass::myFunc() should not be called statically in /in/ioZUE on line 21 Strict Standards: Non-static method MyClass::myFunc() should not be called statically in /in/ioZUE on line 15 MyClass::myFunc() OtherClass::myFunc()

preferences:
233.51 ms | 403 KiB | 371 Q