How to obtain global variables in php

Source: Internet
Author: User
Tags file upload http file upload http post php tutorial

$ Globals --- save all global variables (only on the current page) get_defined_vars () --- return an array composed of all defined variables (including global variables and Super global variables) get_defined_constants () --- returns an array composed of all defined constants.

Function cleanglobal ($ global_array, $ arg, $ specialchars = true, $ default = null ){
If (key_exists ($ arg, $ global_array) & $ global_array [$ arg]! = Null & $ global_array [$ arg]! = ""){
If ($ specialchars ){
Return htmlspecialchars ($ global_array [$ arg]);
} Else {
Return $ global_array [$ arg];
} Else {
Return $ default;

Table of contents
Superglobals-superglobals are built-in variables that are always available in all scopes
$ Globals-references all variables available in global scope
$ _ Server-server and execution environment information
$ _ Get-http get variables
$ _ Post-http post variables
$ _ Files-http file upload variables
$ _ Request-http request variables
$ _ Session-session variables
$ _ Env-environment variables
$ _ Cookie-http cookies
$ Php Tutorial _ errormsg-the previous error message
$ Http_raw_post_data-raw post data
$ Http_response_header-http response headers
$ Argc-the number of arguments passed to script
$ Argv-array of arguments passed to script


Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.