|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-05-18 14:11 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 05 10:00:01 2025 UTC |
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, ,