Updated is_numeric description and example

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@329671 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Dejan Marjanovic 2013-03-05 21:27:21 +00:00
parent 050ac83174
commit bbc0131c88

View file

@ -15,11 +15,12 @@
<methodparam><type>mixed</type><parameter>var</parameter></methodparam>
</methodsynopsis>
<para>
Finds whether the given variable is numeric. Numeric strings consist of
optional sign, any number of digits, optional decimal part and optional
exponential part. Thus <literal>+0123.45e6</literal> is a valid numeric
value. Hexadecimal notation (<literal>0xFF</literal>) is allowed too but
only without sign, decimal and exponential part.
Finds whether the given variable is numeric. Numeric strings consist of optional
sign, any number of digits, optional decimal part and optional exponential part.
Thus <literal>+0123.45e6</literal> is a valid numeric value. Hexadecimal (e.g.
<literal>0xf4c3b00c</literal>), Binary (e.g. <literal>0b10100111001</literal>),
Octal (e.g. <literal>0777</literal>) notation is allowed too but only without
sign, decimal and exponential part.
</para>
</refsect1>
@ -58,7 +59,10 @@
$tests = array(
"42",
1337,
"1e4",
0x539,
02471,
0b10100111001,
1337e0,
"not numeric",
array(),
9.1
@ -79,7 +83,10 @@ foreach ($tests as $element) {
<![CDATA[
'42' is numeric
'1337' is numeric
'1e4' is numeric
'1337' is numeric
'1337' is numeric
'1337' is numeric
'1337' is numeric
'not numeric' is NOT numeric
'Array' is NOT numeric
'9.1' is numeric