file_get_contentsでファイルを取得することは出来るのですが、パスが存在しなかった場合、PHPエラーが出てしまうので、例外処理で対応したいです。
ErrorException in ContactController.php line 65:
file_get_contents(/home/$uuid/result.json): failed to open stream: No such file or directory
ケアレスミスだと思うのですが、どこが間違っているのか調べてもわかりません。
お願いします。
lang
1$path = "/home/$uuid/result.json"; 2 3 /* 4 $context = stream_context_create(array( 5 'http' => array('ignore_errors' => true) 6 ));*/ 7 try{ 8 $json = file_get_contents($path); 9 } 10 catch(Exception $e){ 11 echo '捕捉した例外: ', $e->getMessage(), "\n"; 12 }finally { 13 echo "Second finally.\n"; 14 }
回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/10/12 10:17