Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Brian Enos10,468 Points
Introducing Constants: Difference between "BASE_URL" and "ROOT_PATH
In this video, I'm a bit confused about the difference between the "BASE_URL", and ROOT_PATH" constants in this example.
<?php define ("BASE_URL", "/shirts4mike_local/"); define ("ROOT_PATH", $_SERVER["DOCUMENT_ROOT"] . "/shirts4mike_local/");
Do these two constants not point to the same location? If not, what is the difference? Thanks for any help.
Ben Falk3,167 Points
The easiest way to test this would be to do a quick echo of both constants, and view the difference.
My understanding is that the two items have slightly different purposes.
-- The ROOT_PATH uses $_SERVER['DOCUMENT_ROOT'], which you can learn more about here: http://php.net/manual/en/reserved.variables.server.php. DOCUMENT_ROOT will give you absolute path to document root of the website in server's file system, for example, "/var/www/domain/", which would be useful for using PHP's include() function (or anything else that needs a file path), which has to use a path to the included file, and can't use a URL.
Hope that helps?
Pavle Lucic10,801 Points
Have problem with including config.php file.
In his video, Randy including config.php file into receipt.php (required_once is used), and that is fine. BUT, he doesnt include in header.php, and he calls defined CONSTANTS in it? Could someone explain Am I wrong ?
Kristi Smythe10,665 Points
Some local server configurations (mine) toss a fatal error with a config.php file name conflict, so I changed the config.php for this project to siteConfig.php