title: PHP: fopen error handling
body: <p>I do fetch a file with</p>
  
  <pre><code>$fp = fopen('uploads/Team/img/'.$team_id.'.png', "rb");
  $str = stream_get_contents($fp);
  fclose($fp);
  </code></pre>
  
  <p>and then the method gives it back as image. But when fopen() fails, because the file did not exists, it throws an error:</p>
  
  <pre><code>[{"message":"Warning: fopen(uploads\/Team\/img\/1.png): failed to open stream: No such file or directory in C:\...
  </code></pre>
  
  <p>This is coming back as json, obviously.</p>
  
  <p>The Question is now: How can i catch the error and prevent the method from throwing this error directly to the client?</p>