Bug #71603 [Opn->Fbk]: compact() maintains references in php7

From: Date: Tue, 16 Feb 2016 00:58:03 +0000
Subject: Bug #71603 [Opn->Fbk]: compact() maintains references in php7
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-199239@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71603&edit=1 ID: 71603 Updated by: requinix@php.net Reported by: tim at zaremedia dot com Summary: compact() maintains references in php7 -Status: Open +Status: Feedback Type: Bug -Package: Unknown/Other Function +Package: Scripting Engine problem Operating System: Debian 8 PHP Version: 7.0.3 Block user comment: N Private report: N New Comment: PHP 7's changes also fixed references to work more consistently. Isn't the new behavior better? Since the variable was a reference, shouldn't the array use a reference too? Previous Comments: ------------------------------------------------------------------------ [2016-02-15 23:24:54] tim at zaremedia dot com Description: ------------ When compact() is used with references, those references are maintained in the new array in php7 and not in 5.6 Test script: --------------- <?php $foo = 45; $foo_reference =& $foo; $array = compact('foo_reference'); print_r($array); $foo = 50; print_r($array); Expected result: ---------------- PHP 5.6.17 ---------- Array ( [foo_reference] => 45 ) Array ( [foo_reference] => 45 ) Actual result: -------------- PHP 7.0.3 --------- Array ( [foo_reference] => 45 ) Array ( [foo_reference] => 50 ) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=71603&edit=1

« previous php.bugs (#199239) next »