note 49883 deleted from function.error-reporting by danbrown
| From: | danbrown@php.net | Date: | Fri, 24 Oct 2008 18:39:30 +0000 |
| Subject: | note 49883 deleted from function.error-reporting by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-145710@lists.php.net to get a copy of this message | ||
Note Submitter:
----
Under jjuffermans' note, the editors posted the following:
"Instead of using @ to suppress errors if the file does not exist you should do a conditional
include:
if (is_file("nosuchfile.php")) {
include_once("nosuchfile.php");
}"
This is rather obvious, but has an even more obvious problem: is_file doesn't check on the
include_path, which one assumes include_once is highly likely to be using.
While there are any number of kludgy workarounds which can be employed to overcome this problem,
it's a structural problem in PHP and should be fixed. Preferably @ should only suppress a file
not found error, but not any errors inside the included file if it is found, or failing that at the
least is_file or file_exists should have the option to look on the include_path for the file.