- print_r: documentation ( source)
<?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);
?>