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

Objects in PHP Forum

View Course » View Exercise

441 points
Submitted by
Tom B.
about 3 years ago

Unexpected T_Variable 9/10

For some reason I keep getting this error through the excercices. Eventhough if I click next it will work.
And i've been going through my code but can't find out why i keep getting: Parse error: syntax error, unexpected TVARIABLE, expecting TFUNCTION on line 24 // Line 24 is the $cat1 = new Cat("CodeCat");

          // Your code here
          class Cat {
              public $isAlive = true; 
              public $numLegs = 4; 
              public $name;

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

              function meow(){
                  return "Meow meow";
 $cat1 = new Cat("CodeCat");

 echo $cat1;

It would be awesome if someone could help me out with this.
Thank you in advance!

1 vote


Try moving the function Meow inside the Cat class:

class Cat{

Public var

function __construct(){}
function meow(){}

805 points
Submitted by
Daniel Wright
about 3 years ago