Re: note 12007 added to language.variables.predefined.php

From: Date: Sun, 18 Mar 2001 01:32:31 +0000
Subject: Re: note 12007 added to language.variables.predefined.php
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-12516@lists.php.net to get a copy of this message
Variable names in PHP *cannot* have spaces, and this is clearly mentioned in the "Variables" section of the manual, therefore the behavior you observe is a an attempt to fix incorrectly named variables to conform w/ the expected pattern by the PHP interpreter. The RFCs for URI/URL and CGI specs indicate that: "... The query component is a string of information to be interpreted by the resource ..." and thus variable naming conventions should conform to the specifications that the resource (PHP script in this case) dictates. Scripting languages for the web support variable w/o spaces in their names. This editor is not aware of a web scripting language in which you can use blank space in var names, or use of different number of blank spaces in var names for differentiating between similar named variables. I will add that comment to your note. I would not consider this a real bug, but it is only my opinion. --- djb@unixan.com wrote: > 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 > > > > -- > PHP Notes Mailing List (http://www.php.net/) > To unsubscribe, e-mail: > php-notes-unsubscribe@lists.php.net > For additional commands, e-mail: > php-notes-help@lists.php.net > To contact the list administrators, e-mail: > php-list-admin@lists.php.net > ===== --- Jesus M. Castagnetto <jmcastagnetto@php.net> __________________________________________________ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/

« previous php.notes (#12516) next »