question regarding syntax style in form variables

I have read that there are 3 choices of syntax style for form variables depending on the php version you are running and depending on how is your register_globals parameter set:

$variable

$_POST[‘variable’]

$HTTP_POST_VARS[‘variable’]

I would appreciate if anybody could tell me where i can find and modify this parameter manually to activate each of these choices of syntax. Moreover, I think it might be useful to be able to decide dynamically the type of syntax you must use in your code to access form variables. Furthermore, this would make it easy to migrate the code between different php versions. I guess developers will use something like this, right? For that reason it would be great if somebody could tell me if there is an easy way to do it.

For a POSTED value called variable you can access it based on settings as follows:

$variable will only work if you have register_globals = On in your PHP.INI (Very Dangerous and is now default to OFF in all current versions, and May even be removed in future versions.

$_POST[‘variable’] will work in all current versions and most previous versions regardless of the register_globals settings and is the preferred method of accessing posted variables. this method will not work in very old versions (before Version 4.1), however, if you are using those versions, it’s definitely time to upgrade.

$HTTP_POST_VARS[‘variable’] is an older version but will work same as $_POST again regardless of register_globals settings. I believe this method will still work in current versions but As of PHP 5.0.0, the long PHP predefined variable arrays may be disabled with the register_long_arrays directive.

Please have a look at http://us.php.net/manual/sl/reserved.variables.php for more information

Sponsor our Newsletter | Privacy Policy | Terms of Service