Variables for PHP

Source: Internet
Author: User
Tags http cookie http post
A useful feature of PHP is the way it handles PHP forms. A very important principle to understand is that any element of the form automatically takes effect in the PHP script.

Example#1 a simple HTML form

There is no special place in the form where no special identifiers are used. When the user fills out the form and clicks the submit button, the page action.php will be called. In this file, you can add the following content:

Example#2 printing data from a form

Hello, .
You're a year old.

The output of the script might be: Hello, Joe. You are 22 years old.

$_get usage:

Using get forms is similar, except to use the appropriate get pre-defined variables. GET also applies to query_string (URL in the "?" After the information). So, for example, http://www.example.com/test.php?id=3 contains get data that can be accessed using $_get[' ID '.

All variables that can be obtained by $_get and $_post can be obtained by $_request.

The PHP hyper-global variable          $GLOBALS              contains a reference to a globally valid variable that refers to each current script. The key name of the array is the name of the global variable. $GLOBALS array exists starting with PHP 3. The              $_server              variable is set by the Web server or directly associated with the execution environment of the current script. Similar to the old array $HTTP _server_vars array (still valid but opposed to use).              $_get              A variable that is submitted to the script via a URL request. Similar to the old array $HTTP _get_vars array (still valid but opposed to use).              $_post              The variables that are submitted to the script via the HTTP POST method. Similar to the old array $HTTP _post_vars array (still valid but opposed to use).              $_cookie              The variables that are submitted to the script via the HTTP cookie method. Similar to the old array $HTTP _cookie_vars array (still valid but opposed to use).              $_files              The variables submitted to the script via an HTTP POST file upload. Similar to the old array $HTTP _post_files array (still valid but opposed to use). For more information, see POST method uploads.              $_env              The variables that the execution environment submits to the script. Similar to the old array $HTTP _env_vars array (still valid but opposed to use).              $_request              is submitted to the script through the get,post and COOKIE mechanism, so the array is not trustworthy. The presence or absence of all variables contained in the array and the order of the variables are defined by the Variables_order configuration instructions in php.ini. This array does not have a direct corresponding version before PHP 4.1.0. See Import_request_variables ().    

$_session

         The variable currently registered to the script session. Similar to the old array $HTTP _session_vars array (still valid but opposed to use). For more information, refer to the Session processing functions section.    
  • 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.