PHP import_request_variables() Function

PHP 可用的函数PHP Available Functions

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

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

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

Syntax

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

Parameter Description:

  • $types: Specifies the variables to be imported. The letters G, P, and C can be used to represent 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 via the POST method. Note the order of these letters: when using gp, POST variables will overwrite GET variables with the same name. Any letters other than GPC will be ignored.

  • $prefix: The prefix for variable names, 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.

Examples

Examples

<?php //This will import the GET and POST variables //Use example_ as the prefix import_request_variables("gP", "example_"); echo $example_foo; ?>

PHP 可用的函数PHP Available Functions

Other Extensions