jtcy
asked on
PHP: Object oriented question
I have a class:
class student(
public $name;
public function __construct(){
$name = "yes";
}
public function getName(){
echo($name);
}
}
Why is that the name in getName() doesnt get the updated name? How to solve this?
class student(
public $name;
public function __construct(){
$name = "yes";
}
public function getName(){
echo($name);
}
}
Why is that the name in getName() doesnt get the updated name? How to solve this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
class student {
public $name;
public function __construct(){
$this->name = "yes";
}
public function getName(){
echo($this->name);
}
}
For details of classes in PHP, http://www.php.net/manual/en/language.oop5.php