PHP: Prevent Character Replacement in GET, POST, and COOKIE Names
PHP automatically replaces dots in incoming variable names with underscores. This behavior can be undesirable in some cases. How can we disable it?
Why PHP Replaces Dots
According to PHP.net, dots are not valid characters in variable names. The parser would interpret "varname.ext" as a variable named "varname" followed by the concatenation operator and the string "ext", which is not the intended result.
Alternatives
Despite attempts to prevent this behavior, PHP's parsing mechanism makes it necessary. However, there are ways to work around it:
$_POST['x.y'] = str_replace('_', '.', $_POST['x_y']);
RewriteEngine On RewriteRule .* - [E=DOT:_]
The above is the detailed content of How Can I Prevent PHP from Replacing Dots with Underscores in GET, POST, and COOKIE Variable Names?. For more information, please follow other related articles on the PHP Chinese website!