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

Objects in PHP Forum

View Course » View Exercise

327 points
1ca1ffd7fab636fcffa7842dd88ccce4?s=140&d=retro
Submitted by
hiei5331gmail.com
over 3 years ago

[resolved] 4/10 php

I dont know why I cant pass this.
It seems to me that it works....

<?php
class Person{
public $isAlive = "true";
public $firstname;
public $lastname;
public $age;
}
$teacher = new Person();
$student = new Person();
echo $teacher->isAlive;
?>

Oops, try again. It looks as if you didn't echo the value of '$teacher->isAlive. :-(


7 votes

permalink

Correct solution

<?php
class Person {
public $isAlive = true;
public $firstname;
public $lastname;
public $age;

}
$teacher = new Person();
$student = new Person();
echo $teacher->isAlive;
?>

331 points
52e5288852f863bf230079a0_592455567
Submitted by
Zain Ali
over 3 years ago


1 vote

permalink

Oops, i put "" between true....
I could fix it...

327 points
1ca1ffd7fab636fcffa7842dd88ccce4?s=140&d=retro
Submitted by
hiei5331gmail.com
over 3 years ago


1 vote

permalink

This didn't pass for me until I had an empty line after public $age.

2504 points
30bf4ea4fb0a60da16ee1f3db55678cb?s=140&d=retro
Submitted by
Covington Doan
almost 3 years ago

2 Comments

Picture Denise Yu over 2 years ago

I also had to add two line breaks after public $age ... seems like a bug

5536841ed3292f78a20002a2_242114776 Gustavo Space about 2 years ago

You're right, my code works only after excluding all "tabs" and
"enters" after age.

...$age;}