ID:               27572
 Updated by:       [EMAIL PROTECTED]
 Reported By:      marwan at marvonline dot org
-Status:           Open
+Status:           Wont fix
 Bug Type:         Feature/Change Request
 Operating System: Any
 PHP Version:      Irrelevant
 New Comment:

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. 


Previous Comments:
------------------------------------------------------------------------

[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

Reply via email to