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 trial

WordPress

Is 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

I think it's a matter of preference.

Messy is a matter of opinion, I guess, but React syntax (Angular, as well) is just objectively shorter.

Why 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.