oro
-
Posts
2 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Downloads
Gallery
Store
Posts posted by oro
-
-
I downloaded the two files from the site : index.php and class_lib.php and executed them .
i was getting this error :
Stefan's full name: Stefan Mischook
Notice: Use of undefined constant name - assumed 'name' in /home/andy/Documenten/ServerRoot/class_lib.php on line 31
---> JOHNNY FINGERS
someone ?
Bug In Script ?
in PHP
Posted
line 31 is in bold , is suppose it has to be $this->name ?
class person {
// explicitly adding class properties are optional - but is good practice
var $name;
function __construct($persons_name) {
$this->name = $persons_name;
}
public function get_name() {
return $this->name;
}
//protected methods and properties restrict access to those elements.
protected function set_name($new_name) {
if (name != "Jimmy Two Guns") {
$this->name = strtoupper($new_name);
}
}
}
// 'extends' is the keyword that enables inheritance
class employee extends person {
protected function set_name($new_name) {
if ($new_name == "Stefan Sucks") {
$this->name = $new_name;
}
else if($new_name == "Johnny Fingers") {
parent::set_name($new_name);
}
}
function __construct($employee_name) {
$this->set_name($employee_name);
}
}v