title: How to correctly parse an integer in PHP?
body: <p>I can use <code>intval</code>, but according to the documentation:</p>
  
  <blockquote>
    <p>Strings will most likely return 0 although this depends on the
    leftmost characters of the string. The common rules of integer casting
    apply.</p>
  </blockquote>
  
  <p>... and the value to parse can be <code>0</code>, that is I will not able to distinguish between zero and a <code>string</code>.</p>
  
  <pre class="lang-php prettyprint-override"><code>$value1 = '0';
  $value2 = '15';
  $value3 = 'foo'; // Should throw an exeption
  </code></pre>
  
  <p>Real question is: how can I parse the string and distinguish between a <code>string</code> that cast to <code>0</code> and a zero itself?</p>