file_get_contentsはファイル取得だけでなく、他のサイトのAPIをコールしたりするときに便利ですよね。
ただ、エラー処理を行うには自分でレスポンスヘッダーを解析する必要があります。
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | $result = @file_get_contents(省略); if($result === false) {   if(isset($http_response_header) && count($http_response_header) > 0) {     $status = explode(' ', $http_response_header[0]);     switch($status) {       case 401:         // Unauthorized         break;       case 404:         // Not Found         break;       case 500:         // Internal Server Error         break;       default:         // その他         break;     }   }   else {     // タイムアウト   } } | 
