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 Introducing Constants

Relative paths

So i don't understand, if you move (in video) whole site in different folder, how does it understands where is what ? I don't get it. And i can't complete this part, as i changing everything base/url paths to folder names, / , even empty. Please help me to clear some things out.

4 Answers

Well, i did require_once('inc/config.php'); than include(ROOT_PATH . 'inc/header.php'); ?>

config

<?php

define("BASE_URL","/");
define("ROOT_PATH",$_SERVER["DOCUMENT_ROOT"] . "/");

and the header/footer does not loads, so i have no css, nothin if i remove "ROOT_PATH" from include, it loads, if i edit "ROOT_PATH" to "", not works either.

Navid Mirzaie Milani
Navid Mirzaie Milani
6,274 Points

why don't you just use include_once("../inc/config.php') and if i'm correct everything should work then. So for example if you having a index.php which includes header and footer you can do this

 <?php include_once('../inc/config.php');?>

<div>
<!-- include here header --> 
<?php include_once('../inc/header.php');
?>

etc..

Well, the lesson is about config.php, to use, when you move your entire site, or in need to use paths. I can do as you say, it works, but i'm trying to understand how to use config.php and use the define words.