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'*
To change directories using absolute pathnames, type cd /directory/directory; to change directories using relative pathnames, type cd directory to move one directory below, cd directory/directory to move two directories below, etc.; to jump from anywhere on the filesystem to your login directory, type cd; to change to ...
An absolute path refers to the complete details needed to locate a file or folder, starting from the root element and ending with the other subdirectories. Absolute paths are used in websites and operating systems for locating files and folders. An absolute path is also known as an absolute pathname or full path.
you could try:
require_once(realpath(__DIR__ . '/../config.php'));
Not tested but in theory it is supposed to work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With