This forum is now read-only. Please use our new forums! Go to forums
Parse error: syntax error, unexpected T_OBJECT_OPERATOR on line 18
As in Exercise 5 of “Using Objects in PHP” there seems to be an error which is here no matter what I change. This is the base error I get get when the exercise loads for the first time.
On exercise 5, I was able to progress even though I had a similar error which was related to my first this->firstname = $firstname;
line of code. Anyone able to explain this?
Answer 55187bd086f552fdd20045c5
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 get that issue in line 20, it has some thing to do with the (public function __construct($firstname, $lastname, $age)) please let me know what I have wrong.
HI code2learn, Just to revise back those previous lesson that you might been missing out or skipped through. Brackets, Parenthesis, Coma, Semicolons are very sensitive and critical. To guide you better on this. this->firstname = $firstname; and $this->firstname = $firstname; are completely different meaning and an error. The missing & sign on the above comparison, it’s common to be found in most method declaration way. It will be hard for me to explain but once you finish up the lesson you might understand that $this->firstname = $firstname; holds a part of the method declaration way.Let me know if you find me wrong since I’m partly learning as well.