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! While you're at it, check out some resources Treehouse students have shared here.
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 trialGadisha Snip
1,961 PointsPHP Statements & Comments
I have a question about something the teacher said about what a statement is.
This part I understand and seems logical to me: The way we determine what is a statement is it ends in a semicolon.
But, what does the teacher mean with "because it's all in one line" ?
From the videoscript:
Now if we scroll down in our code and we go down to here, 5:37 where there's not a semicolon, 5:39 it's still considered a statement in PHP because it's all on one line. 5:44 I can still add a semicolon here, 5:45 which I will, and then hit Save, and it's still considered a statement.
1 Answer
Kyle Gunby
23,838 PointsIn that particular line of code, he is opening the php tags, making his one statement and closing the tags. In php the closing tags are an implied semicolon. It's best practice to use semicolons after every statement, but if there is a closing tag, it SHOULD still function.
When he says "because it's all in one line" he is referring to the definition of a php statement. Basically what a statement is, is an executable line. Which is what that is. So since it's all on one executable line, it's still statement without the semicolon.
I hope that answers your question.
Gadisha Snip
1,961 PointsGadisha Snip
1,961 PointsThanks Kyle! I get it now :-)