PHP access to form variables "PHP Note 001"

Source: Internet
Author: User
"" PHP Access form variables [PHP Note 001]

There are three ways that PHP provides access to 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 ']//verbose style

In practical applications, we generally try the medium style. Even using: $_post[' name ' to refer to the form variables, but for easier use, we also create short-style variables, however, in the code, we use this style instead of the automatically selected style to refer to the variable, because the automatic selection of style may bring security problems.

Other than that:

1, Short mark: ($name) is very convenient to use, but PHP because of security reasons, the default does not support this tag. You need to turn on the register_globals configuration option set to ON.

2. Medium mark: ($_post[' name ') allows us to recommend the tag.

3, verbose style: ($HTTP _post_vars[' name ') is the most detailed, but because the performance and ease of use has been deprecated, and it is likely to be deleted later, so if the project is not intended to use on the old version of the server, it is not recommended to try this style;

  • Related Article

    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.