3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface KeyInterface { public function open(); } class MagnetKey implements KeyInterface { public function open() { print 'open by magnet key:'; $this->slide(); } private function slide() { print 'slide down.'; } } class TurnKey implements KeyInterface { public function open() { print 'open by turn key:'; $this->insert(); $this->turn(); } private function insert() { print 'insert key.'; } private function turn() { print 'turn key.'; } } class Key { public function open() { print 'open door:'; $this->insert(); $this->turn(); } private function insert() { print 'insert key.'; } private function turn() { print 'turn key.'; } } class MagnetKeOld extends Key { public function open() { print 'open by magnet key:'; $this->insert(); $this->slide(); } private function slide() { print 'slide key.'; } } $k = new TurnKey(); $k->open(); $mk = new MagnetKey(); $mk->open(); interface Testable { public function test(); } interface MyCountable { public function count(); } abstract class MyAbstract { public abstract function test(); } class MyClass implements Testable, MyCountable { public function test() { print 'this is test method'; } public function count() { print 'this is count method'; } } $o = new MyClass(); $o->test(); $o->count();
Output for 5.6.38, 7.0.0 - 7.0.33, 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.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
open by turn key:insert key.turn key.open by magnet key:slide down.this is test methodthis is count method
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 open by turn key:insert key.turn key.open by magnet key:slide down.this is test methodthis is count method

preferences:
186.78 ms | 402 KiB | 217 Q