ID: 25139
User updated by: sibaz at sibaz dot com
-Summary: optionally parse_str shouldn't mangle fieldnames when
theyre only array indexes
Reported By: sibaz at sibaz dot com
Status: Open
Bug Type: Feature/Change Request
Operating System: All
PHP Version: 4.3.2
New Comment:
Summary was unclearly worded
Previous Comments:
------------------------------------------------------------------------
[2003-08-18 22:35:38] sibaz at sibaz dot com
Description:
------------
Understandably parse_str mangles CGI field names to fit into the PHP
variable name space.
When given a second array parameter the mangled variable names are used
as indexes in the array, as documented. However the more intuitive
implementation would be for the array index to be the actual unmangled
CGI field name specified. It makes more sense to me, to not mangle
variable names, when populating an array.
Clearly a change of existing behaviour would be damaging, so perhaps a
config or ini setting could be used to turn off name mangling for array
indexes, or perhaps a third optional parameter to the function could
dictate whether or not to mangle the names.
The primary need for this is to avoid mangling when using fieldnames
that are sqlfield names. These may contain dots if the field name is
fully qualified to include the table name it is dotted. It seems a
waste to have to invent a separate mangling process for phpfield name
(hiding sqlfield name) just because of unneeded, unpreventable mangling
within php. IMHO $_GET should be an array of unmangled CGI Field
names.
Reproduce code:
---------------
$array=array();
parse_str("this.that=1", $array);
echo serialize($array)."<br>\n";
// prints a:1:{s:9:"this_that";s:1:"1";}
Expected result:
----------------
// ideally it should print a:1:{s:9:"this.that";s:1:"1";}
Actual result:
--------------
// it currently prints a:1:{s:9:"this_that";s:1:"1";}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=25139&edit=1