note 12007 added to language.variables.predefined.php

From: Date: Sat, 17 Mar 2001 22:39:48 +0000
Subject: note 12007 added to language.variables.predefined.php
Groups: php.notes 
Request: Send a blank email to php-notes+get-12511@lists.php.net to get a copy of this message
A note about working with variables whose names have spaces: At the current time, $HTTP_GET_VARS and $HTTP_POST_VARS munges variable names which have spaces in them, according to an existing unresolved bug report: http://www.php.net/bugs.php?id=6685 If you are publishing a general-use PHP script which acts on dynamic form variables, or you are adapting a PHP script to work with another (non-PHP) program which passes along variables with spaces in their name, you will be especially affected. The way it munges is: 1. Any spaces at the beginning of a variable are removed, and 2. Any later spaces are replaced with underscores. Examples for POST variables: "My Name" becomes $HTTP_POST_VARS["My_Name"] " My Name" also becomes $HTTP_POST_VARS["My_Name"] Use these rules to guess what the correct variable name is you need to read. You could also use a PHP function such as the following (its named according to the bug that makes it necessary) to formulate the right variable name: function munge_spaces_6685($variable_name) { return preg_replace(array("/^ +/","/ /"), array("","_"), $variable_name); } -Daniel http://www.php.net/manual/en/language.variables.predefined.php

« previous php.notes (#12511) next »