Closed
Description
Description
I got a strange one :)
There is an inconsistency between php-cgi and php-cli if following conditions are meet.
- Generate an array with
range()
where one argument is a string - Use this array in a foreach-Loop inside a function
- Do maths with the value of an array entry inside the foreach-Loop
- Extension opcache installed and enabled
If the code is run with php-cgi, the value is empty in the math expression.
The cli version seems to work as intended.
The following code:
<?php
function test() {
$array = range(1,"2");
foreach ($array as $i) {
var_dump($i + 1);
}
}
test();
Resulted in this output (only for php-cgi):
float(1)
float(1)
But I expected this output instead:
int(2)
int(3)
PHP Version
PHP 8.0.15, PHP 8.1.2
Operating System
No response