Bug #70910 [Opn->Fbk]: extract() breaks variable references
Edit report at https://bugs.php.net/bug.php?id=70910&edit=1
ID: 70910
Updated by: laruence@php.net
Reported by: php at maisqi dot com
Summary: extract() breaks variable references
-Status: Open
+Status: Feedback
Type: Bug
Package: Scripting Engine problem
Operating System: Windows 8
PHP Version: 7.0.0RC7
-Assigned To:
+Assigned To: laruence
Block user comment: N
Private report: N
New Comment:
actually, I think previously behavior seems bug... current behavior is more reasonable, "it
overwrite the old value".
Previous Comments:
------------------------------------------------------------------------
[2015-11-13 10:57:46] php at maisqi dot com
Description:
------------
extract() sets the values of variables that reference variables, instead of changing the variables
that they point to.
For example, say $ref is a reference to $var; if extract() has a "ref" var to inject in
the current scope, it changes $ref and does nothing to $var -- it breaks the reference.
NOTE: My tests was on PHP 7RC7 64 bits on Windows, though this probably isn't relevant.
Test script:
---------------
<?php
$var = 'original value';
$ref =& $var;
$hash = ['var' => 'new value'];
extract($hash);
echo 'ref: ', $ref, ' var: ', $var;
Expected result:
----------------
ref: new value var: new value
(This is what happens on PHP 5.6/64 bits)
Actual result:
--------------
ref: original value var: new value
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70910&edit=1
Thread (7 messages)