When passing a value to PHP for processing, it is common to check for the existence of the passed value and redefine it as a PHP variable. However, it is troublesome to write such a routine process every time, and if you change the URL parameter name, you will have to work on that part again, which is troublesome. So, if you define the parameter name as a variable name for any URL parameter, the initial processing of variable definition will be easier, and it will be easy and quite efficient when writing a mock version of PHP processing... I thought.
So, let's use PHP variables to make URL parameters PHP variables as they are.
foreach($_REQUEST as $query => $value){
${$query} = (isset($value)) ? $value : '';
}
This defines a PHP variable with the parameter name as the variable name for any URL parameter received.
For example, if you access a "test.php" containing the above code with "test.php?a=test", "test.php" will define the "a" of the URL parameter as the variable "$a". In the same way, if you access it with "test.php?a=test&b=1&c=0", "$a", "$b", and "$c" are defined. Since the global variable of "$_REQUEST" is expanded to a variable variable, you can use either the GET method or the POST method.
The definition status of the variable is
print_r(get_defined_vars());
You can check it out.
However, if you create an app for publishing in this way, you will develop the received values as they are, so there is a high possibility that it will become a security hole for cross-site scripting and various injections, so it is better to limit it to mock development and other uses.