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 trialTristan Nederhoff
Courses Plus Student 2,221 PointsIs it neccesary to start with <?php or is it possible to start with <? only?
<? echo "question"; ?> or <?php echo "question"; ?> Don't they both work perfectly?
2 Answers
Mathieu HAYS
9,623 PointsUsing <? would work but you might encounter issues on some server.
It's a better practice to use <?php
Tristan Nederhoff
Courses Plus Student 2,221 PointsThank you for your comments :)
Andrew Shook
31,709 PointsAndrew Shook
31,709 PointsTo add to what Mathieu said, short tags (<? ?>) are not enabled by default on some servers. So, if you plan to share your code, using them might be a problem since some hosting plans will not allow you to turn them on. That means you might have to go back and change all your short tags into long tags. That's why its considered best practice to use the long tags, because they will always work.
Tristan Nederhoff
Courses Plus Student 2,221 PointsTristan Nederhoff
Courses Plus Student 2,221 Pointsshort tags ()? If that is a short tag, what is a long tag then? Or do i have to follow courses and find out myself? It raises another question b.t.w.
I am used to use a command with () tags. Like:
<?php echo ("Hello"); ?>
instead of :
<?php echo "Hello"; ?>
Andrew Shook
31,709 PointsAndrew Shook
31,709 PointsSorry, I put:
(<? ?>)
But because I didn't put it in a code block the editor just put "()". So, just to make sure everything is clear:
Now for your second question, "echo" is not a true function so you can use it with or without parentheses. There is no right or wrong way with that. Why you can do it either way I have no idea.