Jump to content

oro

New Members
  • Posts

    2
  • Joined

  • Last visited

Posts posted by oro

  1. 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

  2. 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 ?

×
×
  • Create New...