mirror of
https://github.com/php/php-src.git
synced 2026-04-19 14:01:01 +02:00
Add zend_ini_parse_quantity() and deprecate zend_atol(), zend_atoi() zend_atol() and zend_atoi() don't just do number parsing. They also check for a 'K', 'M', or 'G' at the end of the string, and multiply the parsed value out accordingly. Unfortunately, they ignore any other non-numerics between the numeric component and the last character in the string. This means that numbers such as the following are both valid and non-intuitive in their final output. * "123KMG" is interpreted as "123G" -> 132070244352 * "123G " is interpreted as "123 " -> 123 * "123GB" is interpreted as "123B" -> 123 * "123 I like tacos." is also interpreted as "123." -> 123 Currently, in php-src these functions are used only for parsing ini values. In this change we deprecate zend_atol(), zend_atoi(), and introduce a new function with the same behavior, but with the ability to report invalid inputs to the caller. The function's name also makes the behavior less unexpected: zend_ini_parse_quantity(). Co-authored-by: Sara Golemon <pollita@php.net>
31 lines
447 B
PHP
31 lines
447 B
PHP
--TEST--
|
|
Bug #74431 - foreach infinite loop
|
|
--INI--
|
|
opcache.enable=1
|
|
opcache.enable_cli=1
|
|
opcache.optimization_level=0x7fffffff
|
|
--EXTENSIONS--
|
|
opcache
|
|
--FILE--
|
|
<?php
|
|
function test(){
|
|
$arr = [1,2];
|
|
$j = 0;
|
|
$cond = true;
|
|
foreach ($arr as $i => $v){
|
|
while(1){
|
|
if($cond){
|
|
break;
|
|
}
|
|
}
|
|
$j++;
|
|
echo $j."\n";
|
|
if ($j>10) break;
|
|
}
|
|
}
|
|
test();
|
|
?>
|
|
--EXPECT--
|
|
1
|
|
2
|