#40224 [Opn->WFx]: Could PHP leave superglobal array indices alone?

From: Date: Tue, 01 Jan 2008 16:24:12 +0000
Subject: #40224 [Opn->WFx]: Could PHP leave superglobal array indices alone?
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-120981@lists.php.net to get a copy of this message
ID: 40224 Updated by: johannes@php.net Reported By: joem at tempomg dot com -Status: Open +Status: Wont fix Bug Type: Feature/Change Request Operating System: redhat linux PHP Version: 5.2.0 New Comment: This can't be fixed without breaking application relying on that feature. Previous Comments: ------------------------------------------------------------------------ [2007-12-31 23:15:31] michael at chunkycow dot com dot au G'day Why dont you just call it 'title' then: <? if(!empty($_POST['title'])) echo $_POST['title']; ?> you can even make them an array eg. <form method="post"> <input name="title[]" type="text"> <input type="submit"> </form> <? if( (!empty($_POST['title'])) && is_array($_POST['title'])) { foreach($_POST['title'] AS $title) echo $title,'<br>'; } ?> You should be escaping the output for real life code but I'm sure you knew that ;) ------------------------------------------------------------------------ [2007-01-24 20:09:32] joem at tempomg dot com Description: ------------ I think it would make more sense if PHP only replaced '.' and ' ' with '_' when register_globals is turned on, and only for the variables that are registered in the global scope, leaving the superglobals' index names as they are. I understand that variable names can't have '.' or ' ' in them, however it seems that most people use the $_POST['variablename'] method of accessing external variables, and in this case, the spaces and dots make no difference. I could find practically no reference to this behavior in the manual, other than a couple notes I submitted. At the very least, the fact that these characters are replaced should be made more obvious in the manual under "Predefined Variables" at http://us2.php.net/manual/en/language.variables.predefined.php and http://us2.php.net/manual/en/reserved.variables.php Reproduce code: --------------- <form method="post"> <input name="title for page3.php" type="text"> <input type="submit"> </form> Title submitted: <?php if (count($_POST) > 0) echo $_POST['title for page3.php']; ?> Expected result: ---------------- I expect to see the title I submitted print out. Actual result: -------------- The POST key 'title for page3.php' is changed to 'title_for_page3_php', and nothing prints out. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=40224&edit=1

« previous php.bugs (#120981) next »