I’m trying to include a file using:
require_once '../config/configVARS.php';
but I get the error:
Warning: require_once(../config/configVARS.php): failed to open stream: No such file or directory in ..../classes/FileHandler.php on line 2
Fatal error: require_once(): Failed opening required '../config/configVARS.php' (include_path='.:/opt/lampp/lib/php') in ..../classes/FileHandler.php on line 2
If I try to include a file on the same folder i don’t have any error (for ex. when I copy the configVARS file to the same folder i’m able to include it).
I checked permissions and that’s not it (neither ownership).
Any ideas? what can cause it?
Check that the file actually is there, if you are unsure that you are using the right file-name, use an absolute path instead of a relative one.
The magic constant
__DIR__Docs contains the absolute location of the file you write it into, sois often more distinct as you actually seem to know where exactly the file exists – a pre-configured include directory where to look in does not seem necessary.