Home > Archive > PHP Language > May 2004 > why is . converted to _ in $_POST
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
why is . converted to _ in $_POST
|
|
|
| I have a form that contains some file names (eg this.jpg). When the form
posts, and i ready $_POST, I get back this_jpg.
What is happening? how can I turn this off?
--
jcg
ColumbusWebMakers.com
| |
| Andy Hassall 2004-05-27, 7:31 pm |
| On Thu, 27 May 2004 20:10:51 GMT, jcg <hpwebby@ameritech.net> wrote:
>I have a form that contains some file names (eg this.jpg). When the form
>posts, and i ready $_POST, I get back this_jpg.
As the key presumably, and NOT the value?
>What is happening? how can I turn this off?
PHP used to set global variables based on the names of form elements
submitted. Variable names cannot contain '.', so '.' got transformed to '_' in
the variable name.
Looks like this is still being done in $_POST, despite it being unnecessary
(and arguably wrong). Don't believe you can turn it off without editing PHP.
From PHP 4.3.6, see main/php_variables.c:102
/* ensure that we don't have spaces or dots in the variable name (not
binary safe) */
for (p=var; *p; p++) {
switch(*p) {
case ' ':
case '.':
*p='_';
break;
}
}
--
Andy Hassall <andy@andyh.co.uk> / Space: disk usage analysis tool
http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space
| |
| Joel Goldstick 2004-05-27, 7:31 pm |
| Thanks Andy. I decided the quick fix was to do a string replace of _jpg to
..jpg
I didn't realize . is illegal in a variable name. It kinda makes sense
though since that would confict with css.
newsgroups are great!
Joel Goldstick
|
|
|
|
|