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

require_once()

I am having problems with require_once() but if I replace with include_once() it then works

require_once('inc/config/php');

my config.php file is

<?php

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

The module I am in is PHP "Enhancing a Simple PHP Application" > Introduction Constants

2 Answers

Require means that the script requires the file to function and will throw an error if that file cannot be located.

Include will include the file and attempt to run the code in the script even if that file is not successfully located, hence why the script executes with include and not with require. Have you checked your file path is correct?

Thanks Richard. It took sometime but I found the fault.

Please share your solution. I am having similar difficulty.

Hi Ben Goldman Have you attempted to debug your file path to the required file? What error are you getting?