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

Objects in PHP Forum

View Course » View Exercise

197 points
55e7cbf586f5524c7c0004be_666842133
Submitted by
Affable Ayoob
over 1 year ago

Putting It All Together, Part II

Code Pass but Showing this result instant of output
Error : Parse error: syntax error, unexpected T_PUBLIC on line 15


<!DOCTYPE html>


Practice makes perfect!




<?php
class Dog {
public $numLegs = 4;
public $name;
public $bark = "Woof!";
}
public function __construct ($name) {
$this->name = $name;

}

public function bark() {
    return "Woof!";
}

public function greet() {
    return "Hi!  I'm " . $this->name . ".  ";
}

}

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

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


0 votes

permalink

class Dog {
public $numLegs = 4;
public $name;
public $bark = "Woof!";
}
public function __construct ($name) {

Close class ''}'' after all methods.

314 points
3a9ea86003ef2ce0ff6c6b244a7a47f4?s=140&d=retro
Submitted by
Dextorio
over 1 year ago