|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-03-24 11:15 UTC] cmb@php.net
-Status: Open
+Status: Verified
[2021-03-24 11:15 UTC] cmb@php.net
[2021-04-13 16:30 UTC] git@php.net
[2021-04-13 16:30 UTC] git@php.net
-Status: Verified
+Status: Closed
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 06:00:01 2025 UTC |
Description: ------------ When Opcache is enabled, the evaluation of a boolean variable is inconsistent within a switch statement with a default case that is inside of a function scope. If a variable that is assigned a boolean value is passed, the results do not evaluate as expected, however, if a boolean value is directly passed, the evaluation runs as expected. Outside of a function scope, the evaluation runs as expected, regardless of variable assignment. Zend Engine v3.4.0 Zend OPcache v7.4.16 opcache.optimization_level 0x7FFEBFFF opcache.memory_consumption=128 opcache.interned_strings_buffer=8 opcache.max_accelerated_files=4000 opcache.revalidate_freq=2 opcache.fast_shutdown=1 opcache.enable_cli=1 Test script: --------------- <?php function testWithVar() { $booleanVar = false; switch ($booleanVar) { case 'a_test_case': echo 'inside testWithVar - "a_test_case"'; break; default: echo 'inside testWithVar - "default"'; break; } } function testWithVal() { switch (false) { case 'a_test_case': echo 'inside testWithVal - "a_test_case"'; break; default: echo 'inside testWithVal - "default"'; break; } } $booleanVar = false; switch ($booleanVar) { case 'a_test_case': echo 'outside function - "a_test_case"'; break; default: echo 'outside function - "default"'; break; } echo PHP_EOL; testWithVar(); echo PHP_EOL; testWithVal(); Expected result: ---------------- outside function - "default" inside testWithVar - "default" inside testWithVal - "default" Actual result: -------------- outside function - "default" inside testWithVar - "a_test_case" inside testWithVal - "default"