Here is my code:
if (file_exists('config.php')) {
require('config.php'); // This is line 38
}
Which somehow produces the error:
Warning: require(config.php) [function.require]: failed to open stream: No such file or directory in /path/name/file.php on line 38
How on earth is this possible?
Update: The following does work:
if (file_exists(getcwd(). '/config.php')) {
require(getcwd(). '/config.php');
}
Try absolute path. Using dirname(__FILE__)
.
require(dirname(__FILE__) . '/config.php');
The PHP include
and require
operate in the same way and use an include path (include). Therefore will use this path to find the file and if you have not set it correctly it will not look in the current directory.
Use get include path to find out the value for this.
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