The reason PHP is converting your variable name from one.txt
into one_txt
is because dots are not valid in variable names.
For more details, look at the PHP Documentation:
Variable names follow the same rules
as other labels in PHP. A valid
variable name starts with a letter or
underscore, followed by any number of
letters, numbers, or underscores. As a
regular expression, it would be
expressed thus:
'[a-zA-Z_x7f-xff][a-zA-Z0-9_x7f-xff]*'
You can either account for the change (.
to _
) and check for $_REQUEST['one_txt']
or you can make your HTML form pass a valid variable name instead.
Edit:
To follow-up on Michael Borgwardt's comment, here's the text from PHP's documentation about handling variables from external sources:
Dots in incoming variable names
Typically, PHP does not alter the
names of variables when they are
passed into a script. However, it
should be noted that the dot (period,
full stop) is not a valid character in
a PHP variable name. For the reason,
look at it:
<?php
$varname.ext; /* invalid variable name */
?>
Now, what the parser sees is a
variable named $varname, followed by
the string concatenation operator,
followed by the barestring (i.e.
unquoted string which doesn't match
any known key or reserved words)
'ext'. Obviously, this doesn't have
the intended result.
For this reason, it is important to
note that PHP will automatically
replace any dots in incoming variable
names with underscores.
It is indeed a PHP specific thing.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…