Back to the PHP directory

Here I am in the /admin/ folder, index.php file. I define a constant in it:

define('FILE', dirname(__DIR__));

Now I need to go back and open another directory. I define another constant, I try to go back and open the core/ directory, but it doesn’t work:

define('FILE', dirname(__DIR__));
define('ROOT', dirname(FILE));
require(ROOT.'/core/functions.php');

Warning: require(./core/functions.php) [function.require]: failed to open stream: No such file or directory in Z:homeacmswwwadminindex.php on line 6

Fatal error: require() [function.require]: Failed opening required ‘./core/functions.php’ (include_path=’.;/usr/local/php5/PEAR’) in Z:homeacmswwwadminindex.php on line 6

Tell me please, otherwise I’m new to PHP


Answer 1, authority 100%

You are going beyond www.
Apparently you wanted to do something like this:

define('FILE', dirname(__FILE__));
define('ROOT', dirname(FILE));
require(ROOT.'/core/functions.php');

Answer 2

If you know where you are, why not just load everything using a relative path:

require('../core/functions.php');

Leave a reply

Please enter your comment!
Please enter your name here