#42271 [Opn]: extract EXTR_REFS and/or references
| From: | rodji at tut dot by | Date: | Sat, 11 Aug 2007 13:59:41 +0000 |
| Subject: | #42271 [Opn]: extract EXTR_REFS and/or references | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-115969@lists.php.net to get a copy of this message | ||
ID: 42271
User updated by: rodji at tut dot by
Reported By: rodji at tut dot by
Status: Open
Bug Type: Scripting Engine problem
Operating System: Win32 XP sp2.2600
-PHP Version: 4.4.7
+PHP Version: 5.2.3
New Comment:
(added php version)
Previous Comments:
------------------------------------------------------------------------
[2007-08-11 09:29:05] rodji at tut dot by
Description:
------------
Tested on:
Apache/1.3.33 (Win32)
PHP/4.4.7 and 5.2.3
trouble with references in functions
Reproduce code:
---------------
function args_select($args, $args_list, $def_val) {
$r = array();
foreach ($args_list as $key) {
if (array_key_exists($key, $args)){
$r[$key] = $args[$key];
}else{
$r[$key] = $def_val; //equal $r[$key] =& $def_val why???
//$r[$key] = (string)$def_val; //solution#1
}
}
return $r;
}
$argums = array('action'=>'edit', 'id'=>1);
$select = array('action','to_do','back');
//debug_zval_dump(args_select($argums, $select, ''));
extract(args_select($argums, $select, ''), EXTR_OVERWRITE |
EXTR_REFS);
//solution#2 why???
/*$m = args_select($argums, $select, '');
//OR //$m =& args_select($argums, $select, '');
extract($m, EXTR_OVERWRITE | EXTR_REFS);
*/
$to_do = 'new';
debug_zval_dump (&$back);
?>
Expected result:
----------------
&string(0) "" refcount(2)
Actual result:
--------------
&string(3) "new" refcount(3)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=42271&edit=1