PHP Globals with EGPCS Information

PHP Globals with EGPCS Information

EGPCS is the variable parsing order configured as the value of the variable_order directive in the PHP configuration file. It is used to configure the order of PHP superglobal variables $_ENV, $_GET, $_POST, $_COOKIE and $_SERVER. These global array elements are merged together and stored in the $_REQUEST array. If we store values in EGPCS array with the same index, then, the variable parsing order affects $_REQUEST values.

$_REQUEST Data based on variable_order Directive
In the PHP code below shows $_GET, $_POST, $_COOKIE with the same array index. Let the variable_order is configured as GCP. 
$_GET[“keyword”] = “search-action”;
$_POST[“keyword”] = “Search”;
$_COOKIE[“keyword”] = “Temp”;

The PHP print_r() function prints $_REQUEST array values as below. It shows the value of $_POST, since P is the latest one specified in the variable_order settings.
[keyword] = Search

variable_order and register_globals
In older PHP version, it had the feature named as register_globals. When the register_globals is set as “ON” then, the PHP will automatically register the super global elements as the variables and these variable can be found in the global scope. For example, the $_GET[“keyword”], $_POST[“keyword”] and $_COOKIE[“keyword”] variables from the above example can also be used as $keyword. The value will be based on the variable_order. Since, it caused security issues, this feature is removed from PHP as of the version 5.4.0
This PHP code tutorial was published on May 3, 2013.

Previous:Trimming String using PHPNext:Web Page Design using CSS
↑ Back to Top

PHPPHP IntroductionPHP BasicsPHP Shopping CartPHP Contact FormTypes, Variables & OperatorsPHP Data TypesPHP Resource Data TypePHP Data Type ConversionPHP Type JugglingPHP Type HintingPHP VariablesPHP Variable VariblesPHP Variable InterpolationPHP Variable ScopePHP Globals with EGPCS InformationPHP $_SERVER VariablePHP OperatorsPHP Scope Resolution OperatorPHP StringsPHP ArraysPHP FunctionsPHP OOPSPHP FormsAdvancedPHP AJAXRESTful APIPHP DatabasesPHP Sessions and CookiesError and Exception HandlingFiles and DirectoriesPHP Date TimePHP GraphicsPHP XMLPHP Code SamplesPHP FreelancerjQueryWordpressMySQLCSS

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

Show Buttons
Hide Buttons
Social Media Auto Publish Powered By :