Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Extending Object-Oriented PHP Inheritance Extend a Class

Mohammed Abdelhadi
Mohammed Abdelhadi
17,331 Points

Please check my code..

<?php class Developer extends User{ protected $skills = array ();

//add new child class here public function getSkills() { return $this->skills; }

public function setSkills($value) { $this->skills = trim(FILTER_DEFAULT($value, $this->skills)); }

}

User.php
<?php
//do not modify this file
class User {
    protected $name;
    protected $title;

    public function __construct($name = null, $title = null) {
        $this->name = $name;
        $this->title = $title;
    }

    public function __toString() {
        return $this->getSalutation();
    }

    public function getSalutation() {
        return $this->title . " " . $this->name;
    }

    public function getName() {
        return $this->name;
    }

    public function setName($name) {
        $this->name = $name;
    }

    public function getTitle() {
        return $this->title;
    }

    public function setTitle($title) {
        $this->title = $title;
    }
}
Developer.php
<?php
class Developer extends User{
 protected $skills = array ();

//add new child class here
public function getSkills() {
 return $this->skills;
  }

public function setSkills($skill) {
 $this->skills = trim(strip_tags($value, $this->skill));
  }

}

1 Answer

Which part of the task are you currently trying to do? The first part only requires you create the class.

class Developer extends User {}