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 trialAleksandr Vinogradov
12,113 PointsWhy do you keep adding <?php?>. Why don't you combine php and html <?php echo "<div id='123'>."$phpstuff".</div>;?>
As you teach us not to repeat yourself :)
1 Answer
Alex Heil
53,547 Pointshey Aleksandr Vinogradov , you're absolutely right that you could also do it your way with echoing out html within php. however it's actually very common (so you'll see this a lot) to not do it that way, one of the reasons being a sort of separation. when you have pure view code/layout (html) then leaving this block on it's own and putting your logic (php) into it's place makes it much easier to digg through the code later on. but as always it depends on the usecase. so sometimes it's absolutely fine to echo out html directly in php when at other times (think about doing a template for wordpress, joomla or another system with a lot of pure html) separating them is a lot better for code quality.
hope that helps and have a nice day ;)