|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-04-16 13:39 UTC] bwoebi@php.net
-Status: Open
+Status: Duplicate
[2016-04-16 13:39 UTC] bwoebi@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 07 11:00:01 2025 UTC |
Description: ------------ Functions with reference parameters that modify the value of the parameter within a switch() construct return the original value of the reference parameter rather than the modified one. This does not apply if the reference parameter is changed in an if() statement or in plain linear code; PHP 7.0.5 shows the expected behavior in these cases. This problem newly appeared with PHP 7.0.5. The test script below returns with PHP 7.0.4: PHP Version: 7.0.4 23:12:25 Before function call: 1 In function call: 2 After function call: 2 Bug with PHP 7.0.5: PHP Version: 7.0.5 21:14:06 Before function call: 1 In function call: 2 After function call: 1 Test script: --------------- function test_func (& $x) { switch ($x) { case 1: $x = 2; break; case 2: break; } echo "In function call: ".$x."<br>\n"; } $x = 1; echo date ("H:i:s")."<br>\n"; echo "Before function call: ".$x."<br>\n"; test_func ($x); echo "After function call: ".$x."<br>\n"; Expected result: ---------------- Before function call: 1 In function call: 2 After function call: 2 Actual result: -------------- Before function call: 1 In function call: 2 After function call: 1