note 44974 deleted from function.include by tomsommer
| From: | tomsommer@php.net | Date: | Sat, 21 Aug 2004 21:57:42 +0000 |
| Subject: | note 44974 deleted from function.include by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-75072@lists.php.net to get a copy of this message | ||
Note Submitter: rehfeld.us
----
In response to the unamed user who discusses using
@include()
and
eval(@file_get_contents()))
neither are good solutions
proper ways to handle that is to set ERROR_REPORTING to the proper level, or use your include path
defined in php.ini
sometimes those options arent available, if not something based on this function should suffice.
this would support retrieving any values that the included file may return(that is, if you use
return() in your inlcudes)
Please note this WILL throw an error if the to-be-included files' parent directory is not
executable, even if the file does in fact exist in that directory.
again, ERROR_REPORTING is the proper way.
<?php
function quietInclude($main, $backup) {
$includeReturn = false;
if (file_exists($main)) $includeReturn = include($main);
elseif (file_exists($backup)) $includeReturn = include($backup);
return $includeReturn;
}
?>