In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "what is a php predefined array". In daily operation, I believe many people have doubts about what a php predefined array is. The editor consulted all kinds of data and sorted out a simple and easy-to-use operation method. I hope it will be helpful to answer the question of "what is a php predefined array?" Next, please follow the editor to study!
There are 9 php predefined arrays: 1, "$_ SERVER", which is an array containing header information, path, and script location; 2, "$_ GET", an array of variables passed through the GET method; 3, "$_ POST", an array of variables passed through the POST method; 4, "$_ FILES", and so on.
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
Predefined array
Starting with PHP 4.1.0, PHP provides an additional set of predefined arrays that contain data from web servers, clients, runtime environments, and user input, which are very special and are often referred to as automatic global variables or "super" global variables. Is a special array, there is no difference in the mode of operation; different to declare them, in each PHP script default existence, because in PHP users do not have to customize them, so in the custom variables should avoid and predetermined global variables of the same name; they automatically take effect in the global scope, that is, directly in the function can be used, and do not use the global keyword to access them.
The predefined array indicates that the $_ SERVER variable is set by the web server or is directly associated with the execution environment of the current script $_ ENV execution environment submitted to the script variable $_ GET submitted to the script via URL request $_ POST submitted to the script via the http post method $_ REQUEST submitted to the script via get, post and cookie mechanisms Therefore, the array is not trustworthy $_ FILES submitted to the script via http, post file upload variable $_ COOKIE submitted to the script via the http cookies method $_ SESSION variable currently registered with the script session $GLOBALS contains a reference to each current script's global variable scope valid variables. The key name of the array is the name of the global variable
1. Server variable: $_ SERVER
$_ SERVER is an array that contains information such as header information, path, and script location. The entities of the array are created by the web server, and there is no guarantee that all servers will generate all the information. The server may ignore some information or generate some other new information. Like other superglobal arrays, this is an automatic global variable that is valid in all scripts and does not need to be accessed by the global keyword in the methods of functions or objects.
2. Environment variable: $_ ENV
The contents of the $_ ENV array are changed from environment variables in the server where PHP resides to PHP global variables while the PHP parser is running. Many of them are determined by the system on which PHP is running, a complete list is not possible, and you need to look at the system documentation of the server where PHP resides to determine its specific environment variables.
3. URL GET variable: $_ GET
The $_ GET array is also an array of superglobal variables, an array of variables passed through the URL GET method. It belongs to an external variable, that is, the parameters passed through the GET of the URL or form through the $_ get super-global data on the server page.
4. HTTP POST variable: $_ POST
The $_ POST array is an array of variables passed through the HTTP POST method. One of the $_ POST and $_ GET arrays can hold the variables submitted by the form, depending on whether the post or get method is used for the method attribute in the form form tag when the form is submitted. However, using the $_ POST array can only access form data submitted with the post method.
5. Request variable: $_ REQUEST
This associative array contains everything in $_ GET, $_ POST, and $_ COOKIE, but it is slow, so it is not recommended.
6. Upload variables from HTTP file: $_ FILES
When uploading a file using the file input field of the form, you must submit it using post. However, in the server file, you cannot get the contents of the file field in the form through the $_ post super-global array. The $_ files superglobal variable is an array of uploaded file items passed through the post method. $_ FILES is a two-dimensional array containing five subarray elements, the first subscript being the name of the file input field in the form, and the second subscript describing the attributes of the uploaded file.
7. HTTP Cookies: $_ COOKIE
The $_ Cookie superglobal array is a variable that is submitted to the script via the HTTP Cookies method. Usually these Cookies are set to the client browser by the previously executed PHP script through the setCookies () function. When the PHP script extracts a cookie from the client browser, it will automatically convert it into a variable that can access the specified cookie value through the $_ Cookie super-global array and the name of the cookie.
8. Session variable: $_ SESSION
Session control uses session to track users on the server side. When session is opened using the session_start () function on the server page, the global variable can be registered using the $_ SESSION array, and users can access the membership information throughout the site.
9. Global variable: $GLOBALS
$GLOBALS is an array of all defined global variables, and the variable name is the index of the array.
At this point, the study of "what is a predefined array of php" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.