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 trialChristopher Davis
10,399 PointsWhy won't include statements wont work when header is in "inc" file?
I used the include command from the video "Including the header" on the PHP track. I included my files from the inc file and the CSS was broken. When I moved the header file to the main "Shirts 4 Mike" directory, everything functioned as it should. I tried changing the file path on the CSS link reference to go up one file "../css/style.css" but still it did not work. Has anyone else encountered issues with putting the header file in the inc folder? In the mean time, I am going to use the work around of moving all the files to the main folder and driving on with the project. It's just bugging me that I can't figure it out
2 Answers
Ernest Rodriguez
17,643 Pointsyou need to have parenthesis around the file path.
Christopher Davis
10,399 PointsI had two header.php files and I was changing one and not the other. Thanks for the answers. I feel like a dummy right now.
Robert Richey
Courses Plus Student 16,352 PointsRobert Richey
Courses Plus Student 16,352 PointsIt's hard to know for sure without seeing your code. What I can say is that using
include(<file>)
will copy the contents of the file into the location of the include line. So, when choosing a relative path, it's from the file with the include, not from the file being included.