PHP : import_request_ variables() function


The import_request_variables() function is used to import GET/POST/Cookie variables into the global scope


(PHP 4 and above)


import_request_variables (string_types, prefix ) 


Name Description Required /
string_types Some predefined characters indicating which request variable is to be imported. 'G' or 'g' is used for specifying GET, 'P' or 'p' is used for specifying POST and 'C' or 'c' is used for specifying Cookie variables. Order of occurrence of the characters is important. Suppose you mention 'gp', POST variables will override the GET variables. If you use any other characters besides aforementioned characters, they are discarded. Required String
prefix A string which is added before the name of the imported variable. For example, if you have a post value named 'email' and you supply a prefix 'user', the the imported variable name will be 'user_email'.This is an optional parameter. Optional String

Return value:

TRUE on success or FALSE on failure.

Value Type : Boolean.

Example :

import_request_variables("p", "w3r_");
echo $POST['name'].".......................";
echo "<br>";
echo $w3r_name;
<form name="f1" method="post" action="import_request_variables-example1.php">
<input type="text" name="name"><br>
<input type="submit" value="Submit"><br>

Output :


View the example in the browser

See also

PHP Function Reference

Previous: gettype
Next: intval

PHP: Tips of the Day

PHP - how to create a newline character?

Only double quoted strings interpret the escape sequences \r and \n as '0x0D' and '0x0A' respectively, so you want:


Single quoted strings, on the other hand, only know the escape sequences \\ and \'.

So unless you concatenate the single quoted string with a line break generated elsewhere (e. g., using double quoted string "\r\n" or using chr function chr(0x0D).chr(0x0A)), the only other way to have a line break within a single quoted string is to literally type it with your editor:

$s = 'some text before the line break
some text after';

Make sure to check your editor for its line break settings if you require some specific character sequence (\r\n for example).

Ref : https://bit.ly/3hcyege