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 trialMUZ140920 Kudakwashe Murungu
6,316 PointsIntroducing Functions
<?php
function hello(){ echo 'Hello, World!'; }
hello();
So this code runs without closing (?>) the php tag??
2 Answers
Erik McClintock
45,783 PointsKudakwashe,
That's correct. If your file contains nothing but PHP, then the closing tag is optional. In fact, it is generally considered a best practice to omit the closing PHP tag in such cases (as any whitespace put after the closing PHP tag can throw errors in various other scripts).
Erik
MUZ140920 Kudakwashe Murungu
6,316 PointsWell explained, thanks for enlightening me on that buddie