This forum is now read-only. Please use our new forums! Go to forums
Parse error: syntax error, unexpected T_CLASS, expecting T_FUNCTION on line 9
<html>
<head>
<title></title>
</head>
<body>
<p>
<?php
class Person {
class Blogger extends Person {
const cats = 50;
}
static public function say() {
echo "Here are my thoughts!";
}
}
Person::say();
echo Blogger::cats;
?>
</p>
</body>
</html>
What is wrong?
Answer 522299d980ff33ba86002e7e
3 votes
You put the subclass (Blogger) inside the superclass (Person).
Answer 529794bf80ff333f150042f3
0 votes
do not put Blogger inside Person.isolate them from one another just by removing last } and adding } before subClass Blogger. last one more thing put say() method inside class Person.hope it would help……………………. if still doesn’t use this code……………………………..
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
Thanks!
do not put Blogger inside Person.isolate them from one another just by removing last } and adding } before subClass Blogger. last one more thing put say() method inside class Person.hope it would help……………………. if still doesn’t use this code…………………………….. <?php class Person { public static function say(){ echo “Here are my thoughts!”; } } class Blogger extends Person{ const cats=50; } echo Blogger::say(); if (Blogger::cats){ echo Blogger::cats;