import_request_variables
(PHP 4 >= 4.1.0, PHP 5 < 5.4.0)
import_request_variables — Import GET/POST/Cookie variables into the global scope
Description
$types
[, string $prefix
] ) : boolImports GET/POST/Cookie variables into the global scope. It is useful if you disabled register_globals, but would like to see some variables in the global scope.
If you're interested in importing other variables into the global scope, such as $_SERVER, consider using extract().
This function has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0.
Parameters
-
types
-
Using the
types
parameter, you can specify which request variables to import. You can use 'G', 'P' and 'C' characters respectively for GET, POST and Cookie. These characters are not case sensitive, so you can also use any combination of 'g', 'p' and 'c'. POST includes the POST uploaded file information.Note:
Note that the order of the letters matters, as when using "GP", the POST variables will overwrite GET variables with the same name. Any other letters than GPC are discarded.
-
prefix
-
Variable name prefix, prepended before all variable's name imported into the global scope. So if you have a GET value named "userid", and provide a prefix "pref_", then you'll get a global variable named $pref_userid.
Note:
Although the
prefix
parameter is optional, you will get anE_NOTICE
level error if you specify no prefix, or specify an empty string as a prefix. This is a possible security hazard. Notice level errors are not displayed using the default error reporting level.
Examples
Example #1 import_request_variables() example
<?php
// This will import GET and POST vars
// with an "rvar_" prefix
import_request_variables("gp", "rvar_");
echo $rvar_foo;
?>
See Also
- $_REQUEST
- register_globals
- Predefined Variables
- extract() - Import variables into the current symbol table from an array
English translation
You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.
Thank you in advance.
Document created the 30/01/2003, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/php-rf-import-request-variables.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.