title: how to catch hex2bin() warning
body: <p>Came across this today, not sure how to solve it.</p>
  
  <p>I want to catch an <code>E_WARNING</code> level error issued by <a href="http://php.net/manual/en/function.hex2bin.php" rel="nofollow noreferrer">hex2bin()</a>.</p>
  
  <p>I thought I might be able to use a <a href="http://php.net/manual/en/language.exceptions.php" rel="nofollow noreferrer">try()catch()</a> exception method but it did not work.</p>
  
  <pre class="lang-php prettyprint-override"><code>try {
      $foo = hex2bin($bar);
  }
  catch (Exception $e) {
      die('Custom message');
  }
  </code></pre>
  
  <p>The standard E_WARNING that is issued is, of course:</p>
  
  <blockquote>
    <p>Warning: hex2bin(): Input string must be hexadecimal string</p>
  </blockquote>
  
  <p>In this particular situation I do <strong>not</strong> want to use the standard methods to disable errors, such as:</p>
  
  <pre><code>error_reporting(-1);
  error_reporting(E_ALL);
  ini_set("display_errors", 1);
  </code></pre>
  
  <p>Nor do I want to suppress the error using a <code>@hex2bin</code> method.</p>
  
  <p>I actually <em>want</em> to have a custom error displayed, but I just do not seem to be able to find a way to catch when <code>hex2bin</code> throws an error.</p>