PHP access form variable [PHP note 001] [] PHP access form variable [php note 001]
PHP provides three methods to access form variables:
1. $ name;
2. $ _ POST ['name'], $ _ GET ['name'], $ _ REQUEST ['name'],
3. $ HTTP_POST_VARS ['name']
$ Name; // short style
$ _ POST ['name'], $ _ GET ['name'], $ _ REQUEST ['name'], // medium style
$ HTTP_POST_VARS ['name'] // lengthy style
In practical applications, we generally try a moderate style. $ _ POST ['name'] is used to reference form Variables. However, for more convenient use, we also create short-style Variables. However, in the code, we use this style instead of the automatically selected style to reference variables because automatic style selection may cause security issues.
In addition:
1. short tag: ($ name) is very convenient to use, but PHP does not support this tag by default due to security considerations. You must set the register_globals configuration option to on.
2. moderate flag: ($ _ POST ['name']) indicates the flag we recommend.
3. lengthy style: ($ HTTP_POST_VARS ['name']) is the most detailed, but it is likely to be deleted later due to its performance and ease of use, therefore, if the project is not intended to use the old version of the server, we do not recommend that you try this style;