3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Lock { 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 { 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
Deprecated: Creation of dynamic property Door::$lock is deprecated in /in/30qZl on line 25 Deprecated: Creation of dynamic property Door::$connectsTo is deprecated in /in/30qZl on line 26 Warning: Undefined property: Lock::$isLocked in /in/30qZl on line 17 You opened the Door connecting to: bedroom Deprecated: Creation of dynamic property Lock::$isLocked is deprecated in /in/30qZl on line 7 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:
43.32 ms | 402 KiB | 8 Q