Search code examples
phppostparametersunderscore.jsdot

The symbol of dot has been replaced in parameter names on the underscore (PHP)


I send POST param with name "param.name"

If I read the php://input everything ok, but if I try to get param from an array $_POST['param.name'] that it is absent because the dot was replaced to underscore and I need to get param this way $_POST['param_name'].

Maybe some settings in PHP I should tune...

I use PHP 7.4.15


Solution

  • This is expected PHP behavior as mentioned in their official documentation. As far as I know, PHP applies this rule when parsing the $_POST superglobal because of reasons related to backwards compatibility (register_globals).

    The reason for php://input showing your actual parameter name is because this is a raw input stream, showing data that has not yet been parsed by PHP. While $_POST data is parsed.

    In short, avoid using dot notation for PHP input parameter naming or be willing to implement your own parsing mechanism in order to support it.