According to php.net:
The include construct will emit a warning if it cannot find a file; this is different behavior from require, which will emit a fatal error.
However, there's nothing more about possible errors or error handling.
- Does it mean that the only reason why
include
orrequire
may fail is not being able to find the file? There might be any other reasons?
I also found this & this questions about fail handling.
So, considering I want to include another .php file stored on my server following best practices, and I write:
if ( file_exists('myFile.php') ) {
require_once 'myFile.php';
}
- Can I consider this script to be completely "safe"? Will
myFile.php
always be included if it exists?