If I understand, you just need error_reporting
<?
error_reporting(0);
if($fp=opendir('/mydir')) {
//read the directory
}
else {
die("Cannot open directory");
}
?>
Error reporting will default to what is in php.ini. Setting error_reporting(0) at the top of the script will turn off error reporting for this script only.