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

Objects in PHP Forum

View Course » View Exercise

628 points
45d2c674342a02598be7f5cf69baa3f3?s=140&d=retro
Submitted by
Blooms2
about 2 years ago

code let me pass but there's an error on the screen box

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

    ?>

it says" Parse error: syntax error, unexpected ';' on line 13"


0 votes

permalink

I dont see a parse error on line 13 but I do notice that you left out a semicolon on the last line after echo $meow. I'm having the same problem except mine says line 11 and sometimes 17. Just try adding that semicolon and see if it works then.

343 points
B3753145d5984351071046cffa2db451?s=140&d=retro
Submitted by
btawil48
about 2 years ago


0 votes

permalink

  1. you dont need the "="
  2. it should read public function __construct($name) you have it backwards
  3. you are missing a closing bracket and semi-colon, delete the one between public $name and public function__construct($name) and add at the end of the second pub function
  4. change echo $meow to echo $name->meow(); I hope this helps!!!

1012 points
55c3cc359113cb60da0000fe_612425341
Submitted by
Ashley Wilkerson
about 2 years ago