3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Lock { public function unlock() { $this->isLocked = false; echo 'You unlocked the Lock'.PHP_EOL; } public function lock() { $this->isLocked = true; echo 'You locked the Lock'.PHP_EOL; } public function isLocked() { return $this->isLocked; } } class Door { public function __construct(Lock $lock) { $this->lock = $lock; $this->connectsTo = 'bedroom'.PHP_EOL; } public function open() { if($this->lock->isLocked()) { echo 'Cannot open Door. It is locked.'.PHP_EOL; } else { echo 'You opened the Door connecting to: ', $this->connectsTo.PHP_EOL; } } } $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/AEE9l on line 25 Deprecated: Creation of dynamic property Door::$connectsTo is deprecated in /in/AEE9l on line 26 Warning: Undefined property: Lock::$isLocked in /in/AEE9l on line 17 You opened the Door connecting to: bedroom Deprecated: Creation of dynamic property Lock::$isLocked is deprecated in /in/AEE9l 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:
35.02 ms | 402 KiB | 8 Q