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!

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 Object-Oriented PHP Basics (Retired) Properties and Methods Constructor Method

OOP Construct Method - code incorrect?

I'm doing the OOP track and, when writing the exact same code as in the video, it echos out "default_name" instead of what it does in the test (obviously my text differs slightly from that in the video, but everything else is the same).

Any idea why it's displaying "default_name" instead of "Testing"?

class Product {

    public $name = "default_name";
    public $price = 0;
    public $desc = "default description";

    function __contruct($name, $price, $desc) {
        $this->name = $name;
        $this->price = $price;
        $this->desc = $desc;

    public function getInfo() {
        return "Product Name: ". $this->name;

$p = new Product();
$shirt = new Product("Testing", 34.99, "An amazing T-Shirt");

echo $shirt->getInfo();

?> ```

3 Answers

Check out your constructor name. It's very, very close....

Oh wow, i can't believe i missed that! I looked over it at least 10 times.

Thanks Jesse, i really appreciate you taking a look.

No problem. Happens to me all the time!