ID: 27572
Updated by: [EMAIL PROTECTED]
Reported By: marwan at marvonline dot org
Status: Wont fix
Bug Type: Feature/Change Request
Operating System: Any
PHP Version: Irrelevant
New Comment:
Besides that you can work around the magic_gpc thing, I definitely
agree that that should never have been part of PHP either.
Previous Comments:
------------------------------------------------------------------------
[2004-03-11 12:51:58] marwan at marvonline dot org
I just wanted to be clear that I'm only suggesting this when parsing
variable names from POST and GET requests, not when accessing the array
inside a script. Further, it can be done so that both [] and . can be
used to delinate arrays so it wouldn't affect anyone except people who
are passing variable names with a . in them, which PHP forbids anyway.
And making it a switch is as portable as magic_gpc switch.
I wrote up the necessary code if anyone's interested.
------------------------------------------------------------------------
[2004-03-11 12:35:48] [EMAIL PROTECTED]
We use the [] everywhere for array accesses, we can't change it because
it will break a lot of scripts, and by making it a switch you prevent
people from writing portable scripts.
------------------------------------------------------------------------
[2004-03-11 12:05:30] marwan at marvonline dot org
Description:
------------
PHP registers HTML variables that look like arrays as array variables,
which is pretty convenient for packaging form variables.
I'm building a form generator that utilizes this feature a lot. It uses
it something like this:
for ($i=0; $i<count($data['ID']); $i++)
{
echo "<input type=\"hidden\" name=\"data[ID][$i]\"
value=\"{$data['ID'][$i]}\"> "
."<input type=\"text\" name=\"data[Name][$i]\"
value=\"{$data['Name'][$i]\"><br>\n";
}
The (slightly) annoying thing about this is that urlencoding the
variable names replaces the '[' and ']' with three letter codes. If the
arrays are large (as they typically are) this bloats the POST request
quite a lot.
If PHP would consider the '.' as an array operator when registering GET
and POST variables, it would improve matters. The '.' is urlencoded as
a '.' with no charcter inflation. Further, it would only require one
operator instead of two ([ and ]).
The code would then look like:
for ($i=0; $i<count($data['ID']); $i++)
{
echo "<input type=\"hidden\" name=\"data.ID.$i\"
value=\"{$data['ID'][$i]}\"> "
."<input type=\"text\" name=\"data.Name.$i\"
value=\"{$data['Name'][$i]\"><br>\n";
}
Since PHP forbids using the '.' in variable names anyway, this
shouldn't affect much code. To be safe, an INI option could be made to
switch this behaviour on and off.
As far as I can tell, the only function that would need to change would
be php_register_variable_ex in main/php_variables.c
I would be quite willing to re-code the function and hand it to someone
who has CVS access.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=27572&edit=1