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(); if ($k instanceof KeyInterface) { $k->open(); } else { print 'turn key has no open() interface'; } $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 git.master, git.master_jit, rfc.property-hooks
open by turn key:insert key.turn key.open by magnet key:slide down.this is test methodthis is count method

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
59.45 ms | 401 KiB | 8 Q