title: Can I Try-Catch PHP Warnings while loading an html file into DOMDocument?
body: <p>Is it possible to do some sort of try catch that will catch warnings?</p>
  
  <p>e.g.</p>
  
  <pre><code>if (!$dom-&gt;loadHTMLFile($url)) {
      //if cant load file handle error my way
  }
  </code></pre>
  
  <p>For the <code>$url</code> I am using I am getting</p>
  
  <blockquote>
    <p>Warning (2): DOMDocument::loadHTMLFile(MYURL) [domdocument.loadhtmlfile]: failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden
         [APP\controllers\import_controller.php, line 62]</p>
    
    <p>Warning (2): DOMDocument::loadHTMLFile() [domdocument.loadhtmlfile]: I/O warning : failed to load external entity "hMYURL" [APP\controllers\import_controller.php, line 62]</p>
  </blockquote>
  
  <p><strong>I could just suppress the error with <code>@</code>, and do something if the call returns <code>false</code>, but I want to be able to catch the exact warning message and then do something with it.</strong></p>
  
  <p><strong>Is this possible?</strong></p>