reference/var/functions/is-numeric.xml
0817d5b2835f8a47314823338d983fa2c5005dfc
...
...
@@ -45,6 +45,29 @@
45
45
</para>
46
46
</refsect1>
47
47

48
+
<refsect1 role="changelog">
49
+
&reftitle.changelog;
50
+
<informaltable>
51
+
<tgroup cols="2">
52
+
<thead>
53
+
<row>
54
+
<entry>&Version;</entry>
55
+
<entry>&Description;</entry>
56
+
</row>
57
+
</thead>
58
+
<tbody>
59
+
<row>
60
+
<entry>8.0.0</entry>
61
+
<entry>
62
+
Numeric strings ending with whitespace (<literal>"42 "</literal>) will now
63
+
return &true;. Previously, &false; was returned instead.
64
+
</entry>
65
+
</row>
66
+
</tbody>
67
+
</tgroup>
68
+
</informaltable>
69
+
</refsect1>
70
+

48
71
<refsect1 role="examples">
49
72
&reftitle.examples;
50
73
<para>
...
...
@@ -104,6 +127,50 @@ NULL is NOT numeric
104
127
</screen>
105
128
</example>
106
129
</para>
130
+

131
+
<para>
132
+
<example>
133
+
<title><function>is_numeric</function> with whitespace</title>
134
+
<programlisting role="php">
135
+
<![CDATA[
136
+
<?php
137
+
$tests = [
138
+
" 42",
139
+
"42 ",
140
+
"\u{A0}9001", // non-breaking space
141
+
"9001\u{A0}", // non-breaking space
142
+
];
143
+

144
+
foreach ($tests as $element) {
145
+
if (is_numeric($element)) {
146
+
echo var_export($element, true) . " is numeric", PHP_EOL;
147
+
} else {
148
+
echo var_export($element, true) . " is NOT numeric", PHP_EOL;
149
+
}
150
+
}
151
+
?>
152
+
]]>
153
+
</programlisting>
154
+
&example.outputs.8;
155
+
<screen>
156
+
<![CDATA[
157
+
' 42' is numeric
158
+
'42 ' is numeric
159
+
' 9001' is NOT numeric
160
+
'9001 ' is NOT numeric
161
+
]]>
162
+
</screen>
163
+
&example.outputs.7;
164
+
<screen>
165
+
<![CDATA[
166
+
' 42' is numeric
167
+
'42 ' is NOT numeric
168
+
' 9001' is NOT numeric
169
+
'9001 ' is NOT numeric
170
+
]]>
171
+
</screen>
172
+
</example>
173
+
</para>
107
174
</refsect1>
108
175

109
176
<refsect1 role="seealso">
...
...
@@ -119,6 +186,7 @@ NULL is NOT numeric
119
186
<member><function>is_string</function></member>
120
187
<member><function>is_object</function></member>
121
188
<member><function>is_array</function></member>
189
+
<member><function>filter_var</function></member>
122
190
</simplelist>
123
191
</para>
124
192
</refsect1>
125
193