w3resource

PHP : import_request_ variables() function

Description

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

Version:

(PHP 4 and above)

Syntax:

import_request_variables (string_types, prefix ) 

Parameters:

Name Description Required /
Optional
Type
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 :

<html>
<?php
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>
</form>
</html>

Output :

 .......................

View the example in the browser

See also

PHP Function Reference

Previous: gettype
Next: intval



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/php/function-reference/import_request_variables.php