This forum is now read-only. Please use our new forums! Go to forums
I can't figure out what's wrong with my code? 7/10
My code is as following:
<?php
class Dog{
public $numlegs=4;
public $name;
public function __construct($name) {
$this->name = $name;
}
};
?>
When I submit it, I get this message: Oops, try again. Did you create an ‘$numLegs’ property?
What’s wrong?
Answer 5604f7a395e378f95f0005e6
0 votes
u shoud pass both the variables to the constructor ..like this
Answer 5605cf0295e378bf96000122
0 votes
in $numLegs the “l” in legs must be “L”….
Answer 560d59cd51b887c500000323
0 votes
Hi, here’s mine. It passed. (The “oops” messages are not particularly detailed or helpful, I find.)
<?php
class Dog {
public $numLegs = 4;
public $name;
public function__construct($name){
$this->name = $name;
}
?>
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