Jump to content

Recommended Posts

Posted

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 ?

Posted

That likely means that there is a "$" missing before a variable name on line 31. Take a look at that, or post the code from class_lib.php and we can take a look.

 

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...