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 trialShen JIE LIN
10,612 PointsChallenge on Cleaning URLs with Subfolders
Question: There is a file located at htdocs/config/company.php on the server. We need to include that file to get access to some of information about the company. At the very top of the file below, before any of the HTML, include that company.php file using a relative server path.
My Answer <?php require_once($_SERVER["DOCUMENT_ROOT"] . "/config/company.php"); ?>
Please help
I have also tried
<?php include($_SERVER["DOCUMENT_ROOT"] . "/config/company.php"); ?>
4 Answers
James Gill
Courses Plus Student 34,936 PointsShen:
<?php require_once($_SERVER["DOCUMENT_ROOT"] . "../../config/company.php"); ?>
MUZ140603 Killion Machimbidzofa
6,318 Points<?php require_once($_SERVER["DOCUMENT_ROOT"] . "../../config/company.php"); ?>
MUZ140603 Killion Machimbidzofa
6,318 Pointsi cant get thru
William J. Terrell
17,403 PointsThis is the code that I used:
<?php include($_SERVER_ROOT . "config/company.php" ); ?>
Although, I just noticed, $_SERVER_ROOT is never mentioned in the video. In the video, they use $_SERVER["DOCUMENT_ROOT"], so I don't know if my solution is actually correct, or if I just found a loop-hole ^^:
Jimmy Maurice
9,379 Points@William J.Terrell, your solution is correct but i don't understand why.. Like you said, it was never mentioned in the video. What is the difference with $_SERVER["DOCUMENT_ROOT"] For me there is a bug somewhere. It is illogical. Anyway thanks for the solution !
Shen JIE LIN
10,612 PointsShen JIE LIN
10,612 PointsThis problem is solved.