$fd = @fopen ($filename , "r") or die ("Unable to open file.");
use '@' to suppress error messages on each function you want silenced.
and the usage of die is low class in my book.
Does the end user need to see that error message how does your page look when your script dies right in the middle of being parsed?
Be professional.
Set custom error reporting level and do something like ...
$fd = @fopen($filename , "r") or setError("can't open $filename");
where your set error function sets an internal error reference like so:
function setError($errMsg) {
$GLOBALS['ERROR_LOG'][] = $errMsg;
}
at the end of your script call a function similar to this one:
function SEND_ERROR_REPORT() {
/
Method is called on error
will generate email to admin
/
if (is_array($GLOBALS['ERROR_LOG'])) {
// populate the email...
$Email_Body = SHOW_DOMAIN . " generated an error on " .
strftime('%c',time()) . "\n\n";
$Email_Body .= "Requested URI was: " . $_SERVER['PHP_SELF'] . "\n\n";
foreach ($GLOBALS['ERROR_LOG'] as $LOCAL=>$ERROR) {
$Email_Body .= "The " . $LOCAL . " error message was: " . $ERROR . "\n\n";
}
mail(ADMIN_EMAIL, 'Error Report', $Email_Body, 'From: ' . SHOW_DOMAIN .
'<'.ADMIN_EMAIL.'>' );
}
return;
}
This allows far greater control and it notifies you immediately of a problem with the site as well as enabling you to toss the users a complete page with a nice "We're sorry" message instead of spilling your guts to the world and giving script kiddies clues about your weak spots.