PHP海补知识(3)-- 错误抑制

使用@抑制住警告,可做出提示处理

$file="C:\\1.txt";
@fp=fopen($file,'r');
//  if the file is not exist, it won't throw an exception
//handle the exception manually
if(!fp){
    die("file not exist!");
}
else{
    //do sth
}

 

posted @ 2014-09-15 10:06  valentine is me  阅读(119)  评论(0)    收藏  举报