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

vickiecomrie
vickiecomrie
3,248 Points

Isn't it kind of messy and against common standards to intersperse bits of PHP in an HTML web page?

I've only rarely seen this method done before and it seems that it makes a lot more sense to have a separate PHP file just like keeping JS and CSS separate and not inline. Agree?

2 Answers

Hey Vickie,

No, I have to strongly disagree because PHP is meant to intermingle with HTML, CSS, and JavaScript. In fact, it would be much less efficient to completely separate your PHP into another document each time you needed to use PHP. In fact, in the very first PHP page from php.net, the people who make PHP, it has you use some PHP inside of an HTML element and continues on to do so in many different examples because it is the most efficient way to utilize PHP.

vickiecomrie
vickiecomrie
3,248 Points

Wow dude, thanks for jumping on top of this so quickly! Okay, that is an excellent answer. And I will follow that practice from now on!

Namaste,

Vick

Kevin Korte
Kevin Korte
28,148 Points

It goes back to the roots of PHP. Keeping your logic in a separate PHP is fine, but you'll have to intermingle PHP and HTML to get a dynamic webpage.