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