This forum is now read-only. Please use our new forums at discuss.codecademy.com.

Objects in PHP Forum

View Course » View Exercise

1175 points
A5ba1285e8142aa3740cc08378e41d6c?s=140&d=retro
Submitted by
Reianna-Bryant
almost 2 years ago

What does my code pass with no results shown?

This is how my code looks:
**<?php
class Dog {
public $numLegs = 4;
public $name();
public function _construct($name) {
$this->name = $name;
}
public function _
bark() {
return "Woof!";
}
public function __greet() {
return "Hello, I am " . $this->name . " the dog.";
}
}

    $dog1 = new Dog("Barker");
    $dog2 = new Dog("Amigo");

    echo $dog1->bark();
    echo $dog2->greet();
    ?>**

It passes fine, but I get this in the result window:
" Parse error: syntax error, unexpected '(', expecting ',' or ';' on line 12".

Is it something I'm doing, or is the computer programming acting up? Please let me know.