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 trialMorg Clemmons
Courses Plus Student 403 PointsPHP shortcode?
I am asking this question because I am not familiar with the way the WordPress loop is written in PHP. I know that the way I learned is probably only one way, and not extensive enough. The commented version is how I am used to writing and if. I think if I understand this I will be on my way. The way I wrote the echo would be replaced with a while loop that use the same convention; correct?
<?php if (1 > 0) : ?>
<?php echo "hello zero!!!"; ?>
<?php endif; ?>
<?php
/*
if (1 > 0) {
echo "hello zero!!!";
}
*/
?>
3 Answers
. Ali
9,799 PointsHi ya, are you asking about the short tags or trying to understand difference between if and while statement?
Morg Clemmons
Courses Plus Student 403 PointsI am starting to make sense of it now. I think it is just that I am not used to the format of if statement used here. Now after playing with it a little I seem to get it.
Andrew McCormick
17,730 PointsMorg, I almost always use if (...) { .. } However I've been reading a lot of people say that it's better to use if (...) : ... endif; when creating templates or using with a lot of html. http://stackoverflow.com/questions/6023418/when-do-i-use-if-endif-versus-if