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 trialBRAEDEN PLEIN
16,234 PointsWhy add the individual PHP tags?
I'm a little confused as to why you added individual php tags to each line. Can someone explain what this does, and where else this technique could be used?
1 Answer
thomascawthorn
22,986 PointsHey,
As with most things, it comes down to what you find most readable. But also what other people would find most readable. For me, if executing a loop within a block of html, I would open and close php tags where possible similar to Randy.
It also depends how much dynamic content their is too. For example, if your'e hiding/showing loads of things based on the results of an array, a huge quantity of open/close php blocks with long if statements may not be so nice to look at. In this case, I would create my content dynamically.
Arguably, opening and closing php blocks might reduce the load on the server because php has to understand less 'stuff' in the page. I'm not convinced it makes enough of a difference to worry about. Something to google write a blog post on!
Hope this helps,
Tom
Chris Shaw
26,676 PointsChris Shaw
26,676 PointsHi BRAEDEN PLEIN,
Could you please post the link to the video in question as without it we have no clue what you're referring to.