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!
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
Tomasz Sporys11,258 Points
Why do we use php in out html file making a huge mess? I thought that it's a server side language?
Kevin Korte28,147 Points
Generally what your learning in those videos is the very start of using php for dynamic websites. No matter what, you're going to have to have some sort of dynamic logic in the view that is going to dynamically add html.
Usually, what you'd end up using is an MVC framework, that would introduce views, and partials to stitch together a web page, and your php code would pass the information to the views, and than you would have your templates do something that that information that was passed to it. That often is still having to loop through an array of data on the view, but that's not too messy.
Sean HayesCourses Plus Student 8,106 Points
I haven't gotten to the PHP videos on this site yet, too much candy in the store, but I am building a website using PHP and I've seen that PHP can actually clean up pages and make running updates easier.
- Templates: PHP can be used to build templates for sections of your webpages that are repeated over and over across multiple pages. This way when you need to make changes to multiple pages that use the same bits of code, instead of having to look through many pages, you make one change and it spreads across the site.
- Databases: If you are building a simple, static website, PHP is likely more than you will need. But if you are going to talk to a server side database, like SQL, PHP allows you to communicate with that database and use the data.
Not sure if this helped or not