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

absolute paths and relative paths

I didn't understand what's the difference between ROOT_PATH and the BASE_URL ? Don't they point to the same location ? and why do we use one not the other. Thanks in advance

1 Answer

They don't always point to the same path. Someone else will be able to give you a more detailed explanation but here is an overview:

Think of the ROOT_PATH as a folder and BASE_URL as a file. In terms of FTP, a root is the top folder of your website/app/whatevermajigger. For example, you have www.houssam.com. When you upload your site, you will start at the root directory (this is usually assigned to you by whoever manages your server) which might look like "/home/houssam/". Generally the root is not accessible through anything but an FTP connection as you don't want someone looking at the contents without permission.

The BASE_URL is the landing page you decide on. This is usually set up in your php.ini file but you more than likely will not have access to this file, much like your root if you are going through a service like godaddy, but they usually give you the option to change where the BASE_URL points via settings.

Again, I would recommend doing a little bit of your own research and hopefully some of the more advanced form members can give a better, more accurate explanation.

I hope this helps!

-Nicholas