3v4l.org

run code in 300+ PHP versions simultaneously
<?php class User { public $Username; public $Password; public $Inbox; private function __construct($Username, $Password) { $this->Username = $Username; $this->Password = $Password; $this->$Inbox = new Inbox($Username); } public static function Login($Username, $Password) { return new User($Username, $Password); } } class Inbox { public $Messages; public function __construct($Username) { $this->Messages = array(); $this->Messages[] = "Message 1"; $this->Messages[] = "Message 2"; } } $theUser = User::Login("Poopy", "Butt"); echo $theUser->Username; echo $theUser->Password; print_r($theUser->Inbox->Messages); ?>
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined variable $Inbox in /in/K1XF2 on line 12 Deprecated: Creation of dynamic property User::$ is deprecated in /in/K1XF2 on line 12 PoopyButt Warning: Attempt to read property "Messages" on null in /in/K1XF2 on line 34

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:
17.39 ms | 402 KiB | 8 Q