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
varis darasirikul
10,832 PointsTroubles with Enhancing a Simple PHP Application Challenge task 3 about relative server path.
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.
and I wrote this but it doesn't work and i dont know why.
<?php
include('$_SERVER["DOCUMENT_ROOT"]'.'/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>
this is link to a Challenge task (task 2)
10 Answers
andi mitre
Treehouse Guest Teacher<?php include ($_SERVER["DOCUMENT_ROOT"] . "../../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>
andi mitre
Treehouse Guest Teacher<?php include ($_SERVER["DOCUMENT_ROOT"] . "../../config/company.php"); ?>
Ryan Tseng
7,325 PointsGot it: <?php include($_SERVER["DOCUMENT_ROOT"]."../../config/company.php"); ?>
Gerasimos Kourtidis
5,162 Pointstry removing the single quotes around $_SERVER["DOCUMENT_ROOT"]
varis darasirikul
10,832 PointsI have tried but it doesn't work .
varis darasirikul
10,832 PointsI already pass it thank you
Ryan Tseng
7,325 Pointswhat was the solution?
andreih
6,108 PointsI'm not sure that's correct. $_SERVER["DOCUMENT_ROOT"] will give you document root, which is /htdocs/ after that you need to go into /config folder and that is done by . 'config/company.php');
Jimmy Maurice
9,379 PointsThe solution is :
<?php require_once($_SERVER['DOCUMENT_ROOT'] . 'config/company.php'); ?>
Ryan Tseng
7,325 PointsGot it: <?php include($_SERVER["DOCUMENT_ROOT"]."../../config/company.php"); ?>