Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why strings in $_POST can not contain a dot "."?

Tags:

post

php

Basicaly the title say's it all. i had an hidden input on my page where i wanted to set the name to "some.major.uber.setting"

for example: <input type="hidden" name="some.major.uber.setting" value="dummy value" />

and when i looked at the $_POST data it contained "some_major_uber_setting". Can anybody explain this behaviour

like image 532
Gabriel Avatar asked Sep 18 '10 17:09

Gabriel


People also ask

What does $_ POST contain?

$_POST is a predefined variable which is an associative array of key-value pairs passed to a URL by HTTP POST method that uses URLEncoded or multipart/form-data content-type in request. $HTTP_POST_VARS also contains the same information, but is not a superglobal, and now been deprecated.

Why $_ POST is empty?

In my case, when posting from HTTP to HTTPS, the $_POST comes empty. The problem was, that the form had an action like this //example.com When I fixed the URL to https://example.com , the problem disappeared. I think is something related on how the server is setup. I am having the same issues using GoDaddy as a host.

What does dot mean in PHP?

' (dot) operator is PHP's concatenation operator. Two string operands are joined together (characters of right hand string appended to left hand string) and returns a new string.

What is the difference between $post and $_ POST?

$_POST is a superglobal whereas $POST appears to be somebody forgetting the underscore. It could also be a standard variable but more than likely it's a mistake.


1 Answers

That is probably a relict from register_global = On times. $_GET/$_POST variables were turned into standard variables ($_GET['foo'] became $foo). Variable names can't contain dots so they were internally converted.

like image 97
halfdan Avatar answered Oct 21 '22 11:10

halfdan