Why does this basic class not work?
- by kalaba2003
I could not understand why my class does no t work. Returns nothing. Is there any mistake?
class User {
public $first_name;
public $last_name;
public function full_name() {
if(isset($this->first_name) && isset($this->last_name)) {
return $this->first_name . " " . $this->last_name;
} else {
return "No name!";
}
}
public function assign () {
$this->first_name = "Name";
$this->last_name = "Surname";
}
}
$user = new User();
$user->assign();
$user->full_name();
?>