This forum is now read-only. Please use our new forums! Go to forums
Why it always said "Did you set $me equal to new Person();"
I have tied many time to summit Code but It always said “Oops, try again! Did you set $me equal to a new Person();? Don’t forget your semicolon!”. I wrote my code in other webs there aren’t any error. Could any one help me, I’m stuck in this exercise for a week! Here is my code:
// Create a Person class here: class Person {
public $firstname;
public function __construct($firstname){
$this->firstname = $firstname;
}
}
// And create a Person instance called $me here:
$me = new Person("thanva");
Answer 517032474bd1f21223001317
Answer 51def6c39c4e9d18b6001930
It seems like it literally means just to create the class and new class without anything else like properties and methods. It should have asked to say something like “write the general structure of a class and creating an instance (note: there’s no need to write the properties and methods)”. Computer programming is about instruction so I hope they’ll fix their “instruction” as well. Oh well this works.
<?php
// Create a Person class here:
class Person {
}
// And create a Person instance called $me here:
$me = new Person();
?>
1 comments
So true…the instruction should have been stated like you said.
Answer 532972187c82ca806f000e7f
my be this help you, this work for me to next lesson
<?php
// Create a Person class here:
class Person {
}
// And create a Person instance called $me here:
$me = new Person();
echo $me;
?>
2 comments
yes it worked for me also
I also got this problem. Thanks for this!
Answer 528e3d0a80ff3348610004b9
Not fixed yet, I got the same message again and again, I even created a function and echoed it to make sure the instance was correctly created, and it was, but I couldn’t get through the exercise… I’m gonna try with your suggestions, thank you!
Answer 5181734992c2d6502f00026e
Answer 52006763548c356f9a001714
This should help
class Person {
public $isAlive = true;
function __construct($name) {
$this->name = $name;
}
// And create a Person instance called $me here:
$me = new Person();
Answer 531357cd631fe9b91700099b
All efforts failed. Still shows the same message.
Popular free courses
- Free Course
Learn SQL
In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.Beginner friendly,4 LessonsLanguage Fluency - Free Course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner friendly,11 LessonsLanguage Fluency - Free Course
Learn HTML
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.Beginner friendly,6 LessonsLanguage Fluency
3 comments
thank a lot NeelyF. I hope Codecadey will fix this problem in future
ditto on the fix. Thanks NeelyF!
It seems not to like us to work too hard. Anything done outside the immediate scope of what it is asking returns an error.