PHP access form variable [PHP notes 001]

Source: Internet
Author: User
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;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.