file_exists
not working.. Have also tried with realpath
.. Same issue
First checking if the file exists.. file_exists
returns false but the file is loaded anyway
chdir(__DIR__.'/../..');
$file = 'frontend.php';
echo "$file\n";
if(file_exists($file)){
echo "File found\n";
}
else{
echo "File not found\n";
}
require $file;
frontend.php
File not found
Contents of frontend.php
As php.net/file_exists says, the file_exists() function requires:
Path to the file or directory.
So try pre-pending with the path of the directory:
if (file_exists(dirname(__FILE__) . $file)) {
echo "File found\n";
}
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