Reputation: 101
How do I accomplish to move up one folder from absolute path?
File structure:
/folder/
/folder/config.php
/folder/classes/test.php
From test.php I want to include_once or require_once the config.php -file.
I've tried this in test.php, but it doesn't work:
require_once(dirname(__FILE__) . '/../config.php');
Error message: *PHP Fatal error: require_once(): Failed opening required '/loooong-path/classes/../test.php'*
Upvotes: 6
Views: 9281
Reputation: 1626
you could try:
require_once(realpath(__DIR__ . '/../config.php'));
Not tested but in theory it is supposed to work.
Upvotes: 9
Reputation: 32720
Try this :
require_once(dirname(__FILE__).'../config.php');
Upvotes: 0