|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-02-08 20:43 UTC] nikic@php.net
-Status: Open
+Status: Verified
[2018-02-08 20:43 UTC] nikic@php.net
[2018-02-09 14:12 UTC] nikic@php.net
[2018-02-09 14:12 UTC] nikic@php.net
-Status: Verified
+Status: Closed
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 06:00:01 2025 UTC |
Description: ------------ Using this combination of code, $mod remains INT 0 instead of being set to INT 1. The wrapped var_dump however shows the proper value still. I've tested this code on my Debian box with: PHP 7.2.2-1+0~20180205160742.18+stretch~1.gbpb78b58 On my test machine, php cli works properly. However, php fpm shows this particular error. My guess is that this is somewhere in the optimizer. Changing or removing any line prior to the first var_dump will result in proper output. Changing the values from variables to constant will result in proper output. Changing the modulus operator to any other operator will result in a proper output. Test script: --------------- function borken($columns) { $columns = (int) $columns; if ($columns < 1) return 0; $count = count([1,2,3,4,5]); var_dump($mod = ($count % $columns)); var_dump($mod); } borken(2); Expected result: ---------------- int(1) int(1) Actual result: -------------- int(1) int(0)