|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2019-01-30 21:19 UTC] kadler at us dot ibm dot com
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 02:00:01 2025 UTC |
Description: ------------ It seems that on php 7.1 (and only on 7.1), with ZTS when you assign a literal value to a variable, you do not get a copy, but a reference. Thus, when we bind to that variable and change it, the *referenced literal itself* is changed! You can see this with the output: Expected output: date before 2002-10-20 date after 1982-01-24 date before 2002-10-20 date after 1982-01-24 date before 2002-10-20 date after 1982-01-24 Actual output: date before 2002-10-20 date after 1982-01-24 date before 1982-01-24 date after 1982-01-24 date before 1982-01-24 date after 1982-01-24 After the first execution of the loop, the underlying literal value "2002-10-20" on line 28 has been changed to "1982-01-24". Test script: --------------- <?php require_once('connection.inc'); $conn = db2_connect($database, $user, $password); @db2_exec( $conn , "DROP PROCEDURE test147proc" ); db2_exec( $conn , "CREATE PROCEDURE test147proc ( OUT p5 DATE) LANGUAGE SQL BEGIN SET p5 = '24.01.1982'; END" ); db2_commit( $conn ); $prep = db2_prepare($conn, "CALL test147proc (?)"); for( $i=1 ; $i<=3; $i++ ){ $p5 = "2002-10-20"; assert($p5 == "2002-10-20"); db2_bind_param($prep, 1, 'p5', DB2_PARAM_OUT, DB2_CHAR); $result = db2_execute($prep); } db2_close( $conn ); ?> Expected result: ---------------- Test should run without assertion warnings. Actual result: -------------- Assertion warnings are printed: Warning: assert(): assert($p5 == '2002-10-20')