submitted by: Guest
PHP: include a file with error reporting
Sometimes you want to be able to give some feedback if a PHP include has failed. Here is a version using the fopen command, which can search the include path.
code snippet:
<?php
$includefile="foo.php";
//using fopen to verify file. the third parameter triggers include_path search
$handle = fopen($includefile, "r", 1);
if ($handle) {
fclose($handle);
include ($includefile);
} else {
echo "file: $includefile not found in path";
echo "handle is: $handle";
}
?>
notes:
Thanks to feyd and redmonkey at devnetwork.net for pointing me to the fopen solution.



