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 Enhancing a Simple PHP Application Cleaning URLs with Subfolders Server Paths and Constants

What is the answer for step 2? (If this is too short is is because there seems to be a character limit for iPads.

I cannot figure out the answer to this step of the challenge. I have tried the following both before and after the html tag:

Include ("/config/company.php"); Include ("../../config/company.php"); Include ("../config/company.php");

I have also tried without the parents and quotes in all combinations. It is supposed to be a server relative path. The error message always says that I am not including the file. All iterations were enclosed by <?php ........ ?>

My understanding is the code starting with a / should look to the top directory, then follow the path. The path starting with ../ moves up one directory for each sequence. Since we are in about/leadership, we need two to move to the proper folder. I also tried /[whatever the parent folder is]/config/company.php. I looked at the PHP documentation and it looks like the () are not required, but that didn't work.

about/leadership/index.php
<?php
include "../../config/company.php";
?>

<html>
<head>
     <title>Leadership | Shirts 4 Mike</title>
</head>
<body>

    <h1>Leadership</h1>
    <p><strong>Owner:</strong> ????</p>
    <p><a href="/contact/">Contact</a></p>

</body>
</html>

Hampton Paulk ,

Task 2 of this challenge seems to be treating the "config" folder as being inside the "leadership" folder which doesn't match up with the instructions.

3 Answers

Codin - Codesmite
Codin - Codesmite
8,600 Points

I think the question is possibly bugged?

Testing it myself I managed to pass the question with:

<?php
include "./config/company.php";
?>

Which to my understanding would link to the current directory which would be: htdocs/about/leadership/config/company.php and not htdocs/config/company.php which would be accessed with ../../config/company.php as a relative path from where index.php is located.

Hi Ashley,

I think you're right that there is a problem currently with this code challenge. A few others have had the same issue.

It doesn't hurt to have it but you don't need the current directory reference.

"config/company.php" will work too.

Theodore,

The correct answer should have been what you wrote: "../../config/company.php" and your reasoning behind it is correct. Just to get past the challenge, take Ashley's advice and treat the "config" folder as being inside the "leadership" folder.

I will try your answer. I think you are right about the path of your code.

I did Ashley's answer and it was accepted. This quiz needs to be corrected.