Search code examples
phphtmlpostcase-sensitive

Can the METHOD attribute in html and the POST variable in PHP be of different case?


I know the method attribute in HTML form is case insensitive and can have 'post' or 'POST' in it. It is case insensitive.

But my query is, if attribute in HTML is

method="post"

then can we use

$variable=$_POST['variable'] 

in capturing the post in PHP ? Is the case difference ok ?

I mean, can I use $variable = $_post['variable'] or $variable = $_POST['variable'] in my PHP file irrespective of method='post' or method='POST' in the HTML ?


Solution

  • In your html, you can use method="post" or method="POST" it don't matter, but I recommend you to use post.

    Concerning, $_POST variable :

    An associative array of variables passed to the current script via the HTTP POST method when using application/x-www-form-urlencoded or multipart/form-data as the HTTP Content-Type in the request.

    Since it's a variable name, it's case-sensitive.

    Then you can't use $_post. you have to use $_POST.