English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Basic PHP Tutorial

Advanced PHP Tutorial

PHP & MySQL

PHP Reference Manual

Usage and example of PHP import_request_variables() function

PHP available functions

import_request_variables() The function imports GET/POST/Cookie variables into the global scope.This function is no longer supported in the latest version of PHP.

import_request_variables() The function imports GET/POST/Cookie variables into the global scope. If you have disabled register_globals but want to use some global variables, this function is very useful.

Version requirement: PHP 4 >= 4.1.0, PHP 5 < 5.4.0

Syntax

bool import_request_variables ( string $types [, string $prefix ] )

Parameter description:

  • $types: Specify the variables to be imported, which can be represented by the letters G, P, and C for GET, POST, and Cookie, respectively. These letters are case-insensitive, so you can use any combination of g, p, and c. POST includes file information uploaded through the POST method. Note the order of these letters; when using gp, POST variables will overwrite GET variables with the same name. Any letter other than GPC will be ignored.

  • $prefix: The prefix of the variable name, placed before all variables imported into the global scope. So if you have a GET variable named userid and provide pref_ as the prefix, you will get a global variable named $pref_userid. Although the prefix parameter is optional, if you do not specify a prefix or specify an empty string as the prefix, you will get an E_NOTICE level error.

Return value

None.

Online example

<?php
// Here GET and POST variables will be imported
// using w3codebox_ as prefix
import_request_variables("gP", "w"3codebox_);
echo $w3codebox_foo;
?>

PHP available functions