Reputation: 605
I don't know PHP well but also I don't want to stop error reporting.
Please tell me a function which won't display errors or warnings when the file is not found but otherwise works the same as the include function, e.g.
<?php include("file.txt"); ?>
Upvotes: 0
Views: 49
Reputation: 15476
This question should be solved in a way that makes sense, instead of suppressing errors and warnings.
A better way of doing this would be something like:
$include_file = "file.txt";
if( file_exists($include_file) && is_readable($include_file) ) {
include $include_file;
}
Upvotes: 0
Reputation: 2319
You can add @ in the beginning of this function to hide warning e.g.
<?php @include("file.txt"); ?>
This way you will not see warning for only this line of code.
Upvotes: 1