Hey.

PHP question. I want to play with $_REQUEST . To do this, I transmit data simultaneously using the GET and POST methods, while in the first case I set the variables_order in " GP " via .htaccess , in the second - vice versa (" PG "). I expected that in one case in the $ _REQUEST array I would be "Vasia", "35" (entered by hand into the form), and in the other - "John", "25" (taken from? Name = John & age = 25). But I GOT that the variables from $_POST - "Vasia", "35" are ALWAYS in the $ _REQUEST array.

 <form action="\2.php?name=John&age=25" method="POST"> <input type="text" name="name"><br/> <input type="text" name="age"><br/> <input type="submit"><br/> </form> <?php echo ini_get("variables_order");; echo "</br>"; echo "Name:",$_GET["name"]; echo "</br>"; echo "Age:",$_GET["age"]; echo "</br>"; echo "Name:",$_POST["name"]; echo "</br>"; echo "Age:",$_POST["age"]; echo "</br>"; echo "Name:",$_REQUEST["name"]; echo "</br>"; echo "Age:",$_REQUEST["age"]; echo "</br>"; ?> 
  • I only know one thing - it is not good to do GET more than POST - Goncharov Alexander
  • I just want to play these things - Dimon

1 answer 1

Apparently you did not take into account the contents of the request_order directive:

This directive controls the order in which PHP adds the GET, POST and Cookie variables to the _REQUEST array. Adding is done from left to right, new values ​​overwrite old ones.

If the value of this directive is not set, then the value of the variables_order directive is used for the contents of the $ _REQUEST variable.

Note that the php.ini files supplied with the distribution do not contain the value 'C' (cookies) for security reasons.

  • Thanks for the reply, appreciated it. It worked. Why did you think of TWO directives (request_order and variables_order), which regulate the order of entering variables from superglobal arrays in $ _REQUEST? in my opinion, one option would be enough - either request_order or variables_order - Dimon
  • one
    @Dimon, variables_order is used to create superglobal arrays, and request_order to fill in $_REQUEST . - Visman