note 44974 added to function.include
| From: | rehfeld dot us at osu1 dot php dot net | Date: | Sat, 21 Aug 2004 21:53:45 +0000 |
| Subject: | note 44974 added to function.include | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-75071@lists.php.net to get a copy of this message | ||
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;
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.include.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+44974
Delete -- http://master.php.net/manage/user-notes.php?action=delete+44974&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+44974&report=yes
Search -- http://master.php.net/manage/user-notes.php