3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Lock { function unlock() { $this->isLocked = false; echo 'You unlocked the Lock'."\n"; } function lock() { $this->isLocked = true; echo 'You locked the Lock'."\n"; } function isLocked() { return $this->isLocked; } } class Door { function Door(Lock $lock) { $this->lock = $lock; $this->connectsTo = 'bedroom'."\n"; } 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
Warning: Undefined property: Door::$lock in /in/nm5dC on line 30 Fatal error: Uncaught Error: Call to a member function isLocked() on null in /in/nm5dC:30 Stack trace: #0 /in/nm5dC(41): Door->open() #1 {main} thrown in /in/nm5dC on line 30
Process exited with code 255.

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