PHP variables Getting Started tutorial (2) Super Global variable, Total 9

Source: Internet
Author: User
Tags http cookie http post
<span id="Label3"></p><p><p><strong>PHP Hyper-global variables</strong></p></p><p><p><span style="color: #0000ff;">$GLOBALS</span></p></p><p><p>Contains a reference to a globally valid variable that refers to each current script. The Array's key is labeled as the name of the global Variable. $GLOBALS array exists starting with PHP 3.</p></p><p><p><span style="color: #0000ff;">$_server</span></p></p><p><p>Variables are 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).</p></p><p><p><span style="color: #0000ff;">$_get</span></p></p><p><p>A variable that is submitted to the script via the HTTP GET method. Similar to the old array $HTTP _get_vars array (still Valid but opposed to use).</p></p><p><p><span style="color: #0000ff;">$_post</span></p></p><p><p>A variable that is submitted to the script via the HTTP POST method. Similar to the old array $HTTP _post_vars array (still Valid but opposed to use).</p></p><p><p><span style="color: #0000ff;">$_cookie</span></p></p><p><p>A variable that is submitted to the script via the HTTP cookie Method. Similar to the old array $HTTP _cookie_vars array (still Valid but opposed to use).</p></p><p><p><span style="color: #0000ff;">$_files</span></p></p><p><p>A variable that is 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.</p></p><p><p><span style="color: #0000ff;">$_env</span></p></p><p><p>Executes the variables that the environment submits to the Script. Similar to the old array $HTTP _env_vars array (still Valid but opposed to use).</p></p><p><p><span style="color: #0000ff;">$_request</span></p></p><p><p>The variable that is submitted to the script via 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. The array does not directly emulate the earlier version of PHP 4.1.0. See Import_request_variables ().</p></p><p><p><strong>Attention</strong></p></p><p><p>Since PHP 4.3.0, the file information in $_files no longer exists in $_request.</p></p><p><p>Note: when running in command-line mode, this array will not contain argv and argc portals; they already exist in the array $_server.</p></p><p><p><span style="color: #0000ff;">$_session</span></p></p><p><p>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.</p></p><p><p><strong>Variable Range</strong></p></p><p><p>The scope of a variable is the context in which it is defined (translator: plainly, that is, its effective scope). Most PHP variables have a single range. This separate scope span also contains the files introduced by include and Require.</p></p><p><p>Example:</p></p><pre class="brush:php;"><pre class="brush:php;"><?php$a = 1;include "b.inc";? ></pre></pre><p><p>Here the variable $a will take effect in the include file B.inc. however, in a user-defined function, a local function scope is Introduced. Any variables that are used inside the function will be limited to the local function in the default Context.</p></p><p><p>Example:</p></p><pre class="brush:php;"><pre class="brush:php;"><?php$a = 1; /* global scope */function Test () { echo $a;/* reference to local scope variable */}test (); ></pre></pre><p><p>This script does not have any output, because the Echo statement refers to a local version of the variable $a, and within that range, it is not assigned a Value. You may notice that the global variables in PHP are a little different from the C language, and in c, global variables are automatically applied in functions unless overridden by local Variables. This can cause some problems, and some people may inadvertently change a global variable. A global variable in PHP must be declared global when used in a Function.</p></p><p><p>PHP variables Getting Started tutorial (2) Super Global variable, Total 9</p></p></span>

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.