Why does this basic class not work?

Posted by kalaba2003 on Stack Overflow See other posts from Stack Overflow or by kalaba2003
Published on 2012-06-07T22:21:29Z Indexed on 2012/06/07 22:41 UTC
Read the original article Hit count: 122

Filed under:
|

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();



?>

© Stack Overflow or respective owner

Related posts about php

Related posts about class