Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


Francois-Victor LOUVEL
Francois-Victor LOUVEL
1,405 Points

Should the Included PHP file always contain a <?php ?> tag, on top of the one already present on the HTML side ?

I am a bit confused regarding this double <?php ?> tag issue. Will the included file ignore it's own blocks ?

What if i include a file that has many HTML and PHP block and is included within a single PHP block (i.e. <?php include myfile.php ?>) ? Will it simply include it and ignore the bad nesting of tags ?

1 Answer

Darrell Conklin
Darrell Conklin
21,786 Points

It will behave as though it closed the php block before including your php file. If you left a php block open in your included file it will automatically close that block and re-open the php block it was included inside of.

Also, the browser corrects the poorly nested html and places it inside the body of the html doc.