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 trialBence Szatmári
9,235 PointsI don't understand this.
Hi! I want to ask why do we write this if statement here:
<?php
if(strtolower($item['category']) == 'books'){
?> <-----
<?php } ?> <---
Why are we put php open and closing tags where i put the arrows? I hope you can understand what is my problem .
2 Answers
Ashton Norton
7,704 PointsThe reason being is so you can insert HTML. This means that any HTML you put in there, will only appear if your statement is true.
Ashton Norton
7,704 PointsThis works for any other code block too. You can use it in functions and loops. It's pretty useful to use straight html and not have a bunch of echoes. Also makes it more readable.
Bence Szatmári
9,235 PointsBence Szatmári
9,235 PointsSo we are using this because we are not using 'echo "<tr>"' just simple html tags and it will only appear if our statment is true?
Bence Szatmári
9,235 PointsBence Szatmári
9,235 PointsI think I can understand now ! Thank You!