how to validate numeric strings in PHP
<p>I'm looking for a method that would allow me to check for valid IDs in my system. </p>

<p>They're by definition:</p>

<ul>
<li>positive, not 0,</li>
<li>a whole number, but might be bigger than integer size</li>
<li>come as either string or number</li>
</ul>

<p>I'd like to know what you think is the most elegant way of validating this. Candidates that fail are:
- <code>is_int()</code>, because it's valid for negative numbers, AND because of the integer size limit
- <code>is_numeric()</code>, because it'd valid for float, or, say, having an exponential part like this +0123.45e6
- <code>ctype-digit()</code> with casting the input to string, because this would be valid: "0000"</p>

<p>I've so far settled with this:</p>

<pre><code>preg_match('/^[1-9][0-9]*$/',(string)$id);
</code></pre>

<p>Can anyone come up with an alternative?</p>
