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

Objects in PHP Forum

View Course

325 points
Picture
Submitted by
Vipul Garg
over 1 year ago

Exercise 8/10 want to know if code is right!

just want to ask that if i wrote the right code or not!

<!DOCTYPE html>


Practice makes perfect!




<?php
class Dog
{
public $numLegs = 4;
public $name;
public function __construct($name)
{
$this->name = $name;
}
public function bark()
{
return "Woof!";
}
public function greet()
{
return "My name is". $this->name;
}
}
$dog1 = new Dog("Barker");
$dog2 = new Dog("Amigo");
echo $dog1->bark();
echo $dog2->greet();
?>


0 votes

permalink

You got it mate! Thumbs up

439 points
359232948d982bd97142d97a140228cd?s=140&d=retro
Submitted by
Ntokozo
over 1 year ago