3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Lock { private $isLocked = false; public function unlock() { $this->isLocked = false; echo 'You unlocked the Lock'."\n"; } public function lock() { $this->isLocked = true; echo 'You locked the Lock'."\n"; } public function isLocked() { return $this->isLocked; } } class Door { private $lock; private $connectsTo; public function __construct(Lock $lock) { $this->lock = $lock; $this->connectsTo = 'bedroom'."\n"; } public function open() { if($this->lock->isLocked()) { echo 'Cannot open Door. It is locked.'."\n"; } else { echo 'You opened the Door connecting to: ', $this->connectsTo."\n"; } } } $lock = new Lock; $door = new Door($lock); $door->open(); $lock->unlock(); $door->open();
Output for git.master, git.master_jit, rfc.property-hooks
You opened the Door connecting to: bedroom You unlocked the Lock You opened the Door connecting to: bedroom

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:
40.95 ms | 401 KiB | 8 Q