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 = array(); public function __construct($Username) { $this->Messages = array(); $this->Messages[] = "Message 1"; $this->Messages[] = "Message 2"; } } $Username = "Username"; $Password = "Password"; $theUser = User::Login("Poopy", "Butt"); echo $theUser->Username; echo $theUser->Password; echo $theUser->$Username; echo $theUser->$Password; print_r($theUser->Inbox->Messages); var_dump(get_object_vars($theUser)); ?>

preferences:
31.57 ms | 402 KiB | 5 Q