PHP - Classes and Objects
Consider this PHP code:
What is the output?
class User {
public $name;
public $email;
public function __construct($data) {
$this->name = $data['name'] ?? 'Guest';
$this->email = $data['email'] ?? '';
}
}
$user = new User(['email' => 'user@example.com']);
echo $user->name . ' - ' . $user->email;What is the output?
