Type: Sample Code (HOWTO)
License: GNU Library Public License
Description: Code which will extract all the keys from an array and convert them into variables. Useful, if you have code written with register_globals on, and wants the same code to be functional with register_globals off, which is functional from PHP 4.2.0. in which the 'register_globals' setting is off by default. i.e. When you submit a form, and if your code directly uses the field name as variable instead of using HTTP_POST_VARS, then just add the above code at the beginning of the page. All the field names will be set as variables.
/* Code which will extract all the keys from an array and convert them into variables. In this case $HTTP_POST_VARS array which stores the form fields after submission is taken as an example. For e.g. $HTTP_POST_VARS["user_name"] = "abc"; $HTTP_POST_VARS["age"] = 25; */ <?php extract($HTTP_POST_VARS); print $name . "<br>"; print $age . "<br>"; ?> /*OUTPUT*/ abc 25 /***********************/