php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41432 extract() function in php6 does not accept the default prefix character ie. "_"
Submitted: 2007-05-18 13:22 UTC Modified: 2007-05-18 14:11 UTC
From: nikhil dot gupta at in dot ibm dot com Assigned:
Status: Closed Package: Arrays related
PHP Version: 6CVS-2007-05-18 (snap) OS: Linux, win32-xp
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: nikhil dot gupta at in dot ibm dot com
New email:
PHP Version: OS:

 

 [2007-05-18 13:22 UTC] nikhil dot gupta at in dot ibm dot com
Description:
------------
In PHP6, extract() function doesnot prefix the string with default character ("_") when no prefix is provided in argument ,as it does in PHP5. 
According to php5 documentation, output for testcase with php5 is correct. i.e when no prefix is provided, default prefix is "_" (underscore character). Hence while printing the variable _size in php5 , gives correct output ("medium").

Whereas in php6 it gives a warning and notices and refuses to recognize the other variables (color, shape) as well as expected prefixed variable (_size).

Reproduce code:
---------------
<?php
$size = "large";
$var_array = array("color" => "blue",
                   "size"  => "medium",
            	   "shape" => "sphere");
extract($var_array, EXTR_PREFIX_SAME, "");
echo "$color, $size, $shape, $_size\n";
?>

Expected result:
----------------
blue, large, sphere, medium

Actual result:
--------------
PHP Warning:  extract(): prefix is not a valid identifier in /home/nikhil/php/tmp.php on line 7
PHP Notice:  Undefined variable: color in /home/nikhil/php/tmp.php on line 9
PHP Notice:  Undefined variable: shape in /home/nikhil/php/tmp.php on line 9
PHP Notice:  Undefined variable: _size in /home/nikhil/php/tmp.php on line 9
, large, ,

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-05-18 14:11 UTC] tony2001@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Jul 04 15:01:36 2025 UTC