|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-01-24 20:09 UTC] 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. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 04 06:00:01 2025 UTC |
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 ;)