Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
Kyle Block9,297 Points
php error with open and close tags
When watching the php videos often times they will open the php tag in html but not close it, which according to other forums is good practice if you use the php at the end, or if you are using only php in workspaces.
Problem is when i do the same thing as they do in the video, instead of running the program, i get this message
Parse error: syntax error, unexpected end of file, expecting ',' or ';' in /home/treehouse/workspace/index.php
I have to close my php tag in order for the program to run.
So my question is, why does it not work for me?
Kevin Korte28,147 Points
It's likely a syntax error, have you closed every line with a colon? What does your code look like?
Jason AndersTreehouse Moderator 145,854 Points
It is good practice to omit the closing tag if the file is pure PHP, but use the closing tag if it's mixed with HTML. Although there is still back-and-forth debate about this.
As for your error, without seeing your code, this is only a guess, does your last line have it's semicolon? If it does, and you're in workspaces, it may just be how the code checker is. Many times, it checks for all the 'safe' habits (i.e. closing PHP tag). It's kind of like when someone is learning to drive. Many things you are taught is not because it is the law, but rather because it is the safest.