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

Objects in PHP Forum

View Course » View Exercise

934 points
D55c8a6f2a6170eb8ff83994a84ec14c?s=140&d=retro
Submitted by
Fearghal O'Reilly
about 2 years ago

Things that make you go hmmm

So this is 'technically correct' as it allows me to progress but it shows my age in the console as 134!

Any ideas why?

<?php
class Person {
public $isAlive = true;
public $firstname;
public $lastname;
public $age;
public function __construct($firstname, $lastname, $age) {
$this->firstname = $firstname;
$this->lastname = $lastname;
$this->age = $age;
}
}
$teacher = new Person("boring", "12345", 12345);
$student = new Person("Jimmy", "McGurk", 34);
echo $teacher-> isAlive;
echo $student-> age;
?>


0 votes

permalink

Never mind.. Just realized that the 1 represents the teacher...

Remove echo $teacher... I'm back to being 34.

934 points
D55c8a6f2a6170eb8ff83994a84ec14c?s=140&d=retro
Submitted by
Fearghal O'Reilly
about 2 years ago