3v4l.org

run code in 500+ PHP versions simultaneously
<?php class A { public function testMethod() { if(method_exists(static::class, 'toBeOverwritten')) { var_dump('method overwritten'); } else { var_dump('method not overwritten'); } } public function toBeOverwritten(){} } class B extends A { public function callTestMethod() { $this->testMethod(); } } (new B)->callTestMethod();
Output for 5.3.29
Parse error: syntax error, unexpected T_CLASS, expecting T_STRING or T_VARIABLE or '$' in /in/hTQWO on line 7
Process exited with code 255.
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.34, 8.3.0 - 8.3.35, 8.4.1 - 8.4.26, 8.5.0 - 8.5.11
string(18) "method overwritten"

preferences:
33.89 ms | 1140 KiB | 8 Q