This forum is now read-only. Please use our new forums! Go to forums
Why am I getting the error parse error: syntax error, unexpected '{' on line 18?
I have no idea why I’m getting this error. I don’t see any missing or misplaced brackets. I have the usual html, head, and title tags at the top, but I can’t get them to show up for some reason. Here’s my code:
Answer 521bc01d548c35d1dd000376
// Not sure as this works ok, as i just tested and passed with my code below.(i dont see a diff in your code). Try refreshing the page or submitting a few times etc.
<?php
class Shape {
public $hasSides = true;
}
class Square extends Shape {
}
$square = new Square();
// Add your code below!
if (property_exists($square, "hasSides")) {
echo "I have sides!";
}
?>
Answer 525dc862abf821aec50002b1
In line 18 you didnt closed the bracket of property_exists. Try that…You will get the correct answer..!!
1 comments
Just a pair of () and the whole thing doesn’t work =P
Answer 523a39beabf8211b53002723
Answer 5505c40595e37873ef006745
This worked for me just now; Using Waterfox 35.0
<?php
class Shape {
public $hasSides = true;
}
class Square extends Shape {
}
$square = new Square();
// Add your code below!
if (property_exists($square,'hasSides')) {
echo "I have sides!";
}
?>
Answer 55d970449376762b8e000425
the answer was really simple he missed to close the bracket.. why try this and this worked for me..lol
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
2 comments
I also noticed that instead of using the property_exists method, there is a quicker way to get the same result by using “” if ($square->hasSides)”””…
However the example cleary wants us to use the property_exists method instead (to pass the section)
Thanks guys, problem solved!