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
I'm not understanding why PHP doesn't work in tandem with an HTML document...in other words, why don't we need both?
Mark Wade13,112 Points
If you mean the file extension - using ".php" indicates to the server that the file is PHP and HTML. Until you open the php tag, it's treated like a normal HTML file. If you try to put PHP code in a ".html" file, depending on how the server is set up, it might not work.
If you mean why would you have a document with only PHP and no HTML - while often you will insert PHP into a HTML document in the way you're familiar with, PHP does need to be used in conjunction with HTML. For example, you could write a PHP program to send an email and not display anything - in this situation, you wouldn't need any HTML around it. More likely though is that as you develop more complex PHP applications (like Wordpress, Facebook, etc.) you'll want to start with PHP as the entry point and then have it use a tempting engine to decide what HTML and other resources to load. For now though, just think of it as you're just focussing on the PHP part.