@@ -191,8 +191,17 @@ Changes to parameter handling
191
191
192
192
Relevant RFC: https://wiki.php.net/phpng
193
193
194
- Changes to integer operations
195
- -----------------------------
194
+ Changes to integer handling
195
+ ---------------------------
196
+
197
+ * Invalid octal literals (containing digits larger than 7) now produce compile
198
+ errors. For example, the following is no longer valid:
199
+
200
+ $i = 0781; // 8 is not a valid octal digit!
201
+
202
+ Previously the invalid digits (and any following valid digits) were simply
203
+ ignored. As such $i previously held the value 7, because the last two digits
204
+ were silently discarded.
196
205
197
206
* Bitwise shifts by negative numbers will now throw a warning and return false:
198
207
@@ -211,10 +220,33 @@ Changes to integer operations
211
220
* Similarly right bitwise shifts by a number of bits beyond the bit width of an
212
221
integer will always result in 0 or -1 (depending on sign):
213
222
214
- var_dump(1 >> 64); // int(0)
215
- var_dump(-1) >> 64); // int(-1)
223
+ var_dump(1 >> 64); // int(0)
224
+ var_dump(-1 >> 64); // int(-1)
225
+
226
+ * Strings that contain hexadecimal numbers are no longer considered to be
227
+ numeric and don't receive special treatment anymore. Some examples of the
228
+ new behavior:
216
229
217
- Relevant RFC: https://wiki.php.net/rfc/integer_semantics
230
+ var_dump("0x123" == "291"); // bool(false) (previously true)
231
+ var_dump(is_numeric("0x123")); // bool(false) (previously true)
232
+ var_dump("0xe" + "0x1"); // int(0) (previously 16)
233
+
234
+ var_dump(substr("foo", "0x1")); // string(3) "foo" (previously "oo")
235
+ // Notice: A non well formed numeric value encountered
236
+
237
+ filter_var() can be used to check if a string contains a hexadecimal number
238
+ or convert such a string into an integer:
239
+
240
+ $str = "0xffff";
241
+ $int = filter_var($str, FILTER_VALIDATE_INT, FILTER_FLAG_ALLOW_HEX);
242
+ if (false === $int) {
243
+ throw new Exception("Invalid integer!");
244
+ }
245
+ var_dump($num); // int(65535)
246
+
247
+ Relevant RFCs:
248
+ * https://wiki.php.net/rfc/integer_semantics
249
+ * https://wiki.php.net/rfc/remove_hex_support_in_numeric_strings
218
250
219
251
Other core changes
220
252
------------------
@@ -238,15 +270,7 @@ Other core changes
238
270
. Added zend_memnrstr, zend_memnrstr_ex.
239
271
. Added hybrid sorting algo zend_sort for better performance.
240
272
. Added stable sorting algo zend_insert_sort.
241
- . Invalid octal literals in source code now produce compile errors, fixing
242
- PHPSadness #31. Previously, the invalid digits (and any following valid
243
- digits) were simply ignored, such that 0781 became 7.
244
273
. Removed dl() function on fpm-fcgi.
245
- . Removed support for hexadecimal numeric strings. This means that some
246
- operations like == will no longer specially interpret strings containing
247
- hexadecimal numbers. Furthermore is_numeric() will not consider hexadecimal
248
- strings to be numeric (use FILTER_VALIDATE_INT instead).
249
- (RFC: https://wiki.php.net/rfc/remove_hex_support_in_numeric_strings)
250
274
. $HTTP_RAW_POST_DATA is no longer available. Use the php://input stream instead.
251
275
252
276
Other
0 commit comments