Reputation: 376
I am doing PHP lessons in codecademy and i'm stuck near the end. I'd realy appreciate some help here. From my i got i think i did my tasks. Here is how it is exactly said :
The public properties $firstname, $lastname and $age should get a value via a constructor. Change the code, so $teacher's: $firstname is "boring", $lastname is "12345", $age is 12345 Add your $firstname, $lastname and $age to $student. echo the $age of $student.
And i keep getting the messege:
Oops, try again. Hey, did you forget add my name as a property to the object? :-P
<?php
class Person {
public $isAlive = true;
public $firstname;
public $lastname;
public $age;
// public function _contstruct You can do it!
public function __construct($firstname, $lastname, $age) {
$this->firstname = $firstname;
$this->lastname = $lastname;
$this->age = $age;
}
}
$teacher = new Person("Boring","12345",12345);
$student = new Person("Stud","Nenti",19);
echo $teacher->isAlive;
echo $student->age;
?>
Upvotes: 1
Views: 2660
Reputation: 316
The code you wrote is correct as far as I know. However, it might just be an issue of case-sensitivity.
When a Codecademy lesson checks to see if you did it right, it runs a script that checks for variable values, console output, etc. Sometimes, the checks are very picky about being exact. It might be checking for "boring"
(from the instructions) instead of "Boring"
(what you wrote in your code).
Upvotes: 2