Developer's Manual  Function Reference  Working with server variables  getGPCVar

getGPCVar

Returns value of requested GET, POST, cookie, or SESSION variable.


mixed getGPCVar
(string variable_name [, mixed default_value [, string search_order]])

The function getGPCVar returns the value of requested GET, POST, cookie, or SESSION variable or default_value if the variable doesn't exist. If default_value is omitted the function returns zero. The functions looks for the variable in the order specified by search_order. If search_order is omitted the order is GET, POST, COOKIE, SESSION.

Example

<?
$pageid
= getGPCVar('pageid');
if(!
$pageid)
    echo
"Please specify page id";

// Search variable in POST, then in GET and then in SESSION
$pageid = getGPCVar('pageid', 0, 'PGS');
if(!
$pageid)
    echo
"Please specify page id";

?>
Please login to add comments.