note 42032 deleted from function.include by tomsommer
| From: | tomsommer@php.net | Date: | Sat, 21 Aug 2004 21:58:07 +0000 |
| Subject: | note 42032 deleted from function.include by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-75073@lists.php.net to get a copy of this message | ||
Note Submitter:
----
Especially in interactive applications with PHP5, with __autoload it is useful to have two locations
you want to check. Of course, we don't want errors spewing out all over the place if the first
place fails so we use a @. For instance:
<?php
function __autoload($class) {
if(!@include("$class.php")) {
@include("someotherplace/$class.php");
}
?>
However this would have undesired side effects of the included files themselves not reporting any
errors. That is, if a warning, error, etc was thrown in the included file itself, it would not be
shown. Here is my solution:
<?php
function includeNice($file) {
eval(@file_get_contents($file));
}
?>
But keep in mind, for some reason, eval() is slower than regular parsing, so it may not be good for
high-load sites.
Also note that you will not know the file that the error was on, so if you have many includes, this
may not be your best option.
include() really needs an option for this, or another function.