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

PHP PHP Basics (Retired) PHP Operators Operators

Seth Warner
Seth Warner
5,348 Points

writing it a cleaner, more efficient way?

Could you do this like CSS for php

<ul> <li> <?php echo $sum; echo $diff

?> </li> </ul>

Or do you have to close off each echo with its own <?php?> around it.

Seth Warner
Seth Warner
5,348 Points

with a ; at the end of diff of course, sorry I didnt see that.

1 Answer

Seth,

From what I am understanding of your question, if you want to, you can have a complete PHP script on just one line so long as you are separating the statements with a semicolon. It's not advisable as it will be hard to decipher later on by yourself or someone else. If you are asking if you can echo two variables on the same echo statement; you can. You either have to encase them inside of double-quotes or use the period (.) to append them together. Hope this helps.

Cheers!