Remember to create a new cat outside the function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | <!DOCTYPE html> <html> <head> <title> Challenge Time! </title> <link type='text/css' rel='stylesheet' href='style.css'/> </head> <body> <p> <?php class Cat { public $isAlive = true; public $numLegs = 4; public function __construct($name) { $this->name = $name; } public function meow() { return "Meow meow"; } } $cat1 = new Cat("CodeCat"); echo $cat1->meow(); ?> </p> </body> </html> |