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

Objects in PHP Forum

View Course » View Exercise

681 points
Abbf1a7def6935ed5d07722a70d9f180?s=140&d=retro
Submitted by
Christian
almost 3 years ago

Can't see the construct.

Here is the code:

<?php
class Cat {
public $isAlive = true;
public $numLegs = 4;
public $name;

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

public function meow() {
return "Meow meow";
}
}
$cat1 = new Cat("CodeCat");
echo $cat1->meow();
`?>

I Get the Meow Meow so i'm assuming the construct is working otherwise CodeCat would not be calling the method...so...somebody please help me troubleshoot this...I want to get away from PHP asap and go back to JS. I'm just doing this to understand the syntax differences...but this is pointless sitting around trying to figure out why the computer won't let me pass.


2 votes

permalink

<!DOCTYPE html>


Challenge Time!




<?php
class Cat {
public $isAlive = true;
public $numLegs = 4;
public $name;

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

public function meow() {
return "Meow meow";
}
}
$cat1 = new Cat("CodeCat");
echo $cat1->meow();
?>

541 points
Acb54d9c843918c5b825f6d5ff5a88ef?s=140&d=retro
Submitted by
echoyesenia
almost 3 years ago


0 votes

permalink

I was getting the same problem, but I had misspelled the word "construct".

2161 points
Picture
Submitted by
Bill
almost 3 years ago