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 trialAndrew Folts
14,238 PointsIs there a way to keep php + html less messy—like React + html (ex. <div class='{{example}}'></div>)?
I get so sick of tying all these <?php ?> tags and code written with php looks so messy... ie:
<section class='<?php echo $classes ?>' background="<?php echo $bgi ?>">
</section>
In React, it could just be this (which is much cleaner):
<section class='{{example}}' background="{{example}}">
</section>
Are there any ways to make php + html cleaner and more concise?
1 Answer
Aurelian Spodarec
10,801 PointsI think it's a matter of preference.
Andrew Folts
14,238 PointsAndrew Folts
14,238 PointsMessy is a matter of opinion, I guess, but React syntax (Angular, as well) is just objectively shorter.
Aurelian Spodarec
10,801 PointsAurelian Spodarec
10,801 PointsWhy it's messy? {{}} seems messy to me, and it's the same as <?php ?>.
Sure, it migth be shorter, but it's different, doing exactly the same thing.