3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public function name() { return self::class; } } class B extends A {} echo (new A())->name().PHP_EOL; echo (new B())->name().PHP_EOL; class AA { public function name() { return static::class; } } class BA extends AA {} echo (new AA())->name().PHP_EOL; echo (new BA())->name().PHP_EOL;
Output for 5.5.0 - 5.5.36, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.29, 8.2.0 - 8.2.20, 8.3.0 - 8.3.8
A A AA BA

preferences:
208.83 ms | 404 KiB | 234 Q