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

Objects in PHP Forum

View Course » View Exercise

124 points
34bd3eda95419f3f873a50e69f4548d8?s=140&d=retro
Submitted by
prophetezio
over 2 years ago

syntax error, unexpected '(', expecting '{' on line 10

submitted succesfully but doesn't display in window

<!DOCTYPE html>


Challenge Time!




<?php
public class cat(){
public $isAlive = true;
public $numLegs = 4;
public $name;

            public function __construct($name){
                $this->name = $name;
            }

            public function meow(){
                return "Meow meow";
            }
        }

        $kitty = new cat("CodeCat");

        echo meow();
    ?>
  </p>
</body>

2 votes

permalink

class Cat{
public $isAlive=true;
public $numLegs=4;
public $name;
public function __constructor($name){
$this->name=$name;
}
public function meow(){
return "Meow meow";
}
}
$cat1= new Cat("CodeCat");
echo $cat1->meow();

376 points
C6499f2ca3409404e0eb87f2c2973aa1?s=140&d=retro
Submitted by
gougoutham
over 2 years ago

1 Comment

C6499f2ca3409404e0eb87f2c2973aa1?s=140&d=retro gougoutham over 2 years ago

in class Cat() remove curly brace"()" i.e in beging creating "class Cat() to class Cat"