Superglobal variables are internal variables that can always be used in all scopes . There is also no need to execute global $variable; in a function or method to access them.
【$GLOBALS】
References all variables available in the global scope. Is a global combined array containing global variables, the name of the variable is the key of the array.
【$_SERVER】
An array containing header information, path, script location and other information. The elements of this array are created by the web server.
PHP_SELF: The file name of the currently executing script, related to document root. For example: a script with the address http://example.com/test/php/foo.bar, $_SERVER['PHP_SELF']='/test.php/foo.bar'. (The FILE constant contains the full path and file name of the current file)
argv: Array of parameters passed to the script. When the script is run in CLI mode, argv is passed to the program as C-style command line arguments. When called through GET, the change contains Query String.
argc: The number of arguments passed to the script in CLI run mode.
GATEWAY_INTERFACE: The version of the CGI specification used by the server. For example: "CGI/1.1".
SERVER_ADDR: The IP address of the server where the script is currently running.
SERVER_NAME: The host name of the server where the script is currently running. If the script is running in a virtual host, this variable is determined by the value set by the virtual host.
SERVER_SOFTWARE: Server identification string, given in the header information of the response request.
SERVER_PROTOCOL: The name and version of the communication protocol when requesting the page. For example: "HTTP/1.0".
REQUEST_METHOD: The method used to access the page. Such as: GET, HEAD, POST, PUT. (If the request method is HEAD, the PHP script will terminate after the Header header information, no output will be produced, and there will be no output buffering)
REQUEST_TIME: The timestamp when the request started.
QUERY_STRING: Query string. If available, page access is made through it.
DOCUMENT_ROOT: The document root directory where the currently running script is located. Defined in the server configuration file.
HTTP_ACCEPT: The content of the Accept item in the current request header (if it exists).
HTTP_ACCEPT_CHARSET: The content of the Accept-Charset item in the current request header (if it exists).
HTTP_ACCEPT_ENCODING: The content of the Accept-Encoding item in the current request (if it exists).
HTTP_ACCEPT_LANGUAGE: The content of the Accept-Language item in the current request (if it exists).
HTTP_CONNECTION: The content of the Connection item in the current request header (if it exists).
HTTP_HOST: The content of the Host item in the current request header (if it exists).
HTTP_REFERER: Directs the user agent to the address of the previous page of the current page (if it exists). Determined by user agent settings. Not all users will set this item, and some also provide the function of modifying HTTP_REFERER. So the value is not trustworthy.
HTTP_USER_AGENT: The content of the User-Agent item in the current request header (if it exists). This string indicates the user agent information for accessing this page, such as: Mozilla/4.5[en] (X11;U;Linux 2.2.9 i586). In addition, the value can be obtained using get_browser().
HTTPS: If the script is accessed via the HTTPS protocol, this value is set to a non-empty value. When using the ISAPI method on IIS, if it is not accessed through the HTTPS protocol, the value will be off.
REMOTE_ADDR: The IP address of the user browsing the current page.
REMOTE_HOST: The host name of the user browsing the current page. DNS reverse resolution does not depend on the user's REMOTE_ADDR. The server must be configured in order to generate this variable, such as setting HostnameLookups On in Apache.
REMOTE_PORT: The port number used by the user machine to connect to the Web server.
SCRIPT_FILENAME: The absolute path of the currently executing script.
SERVER_ADMIN: This value specifies the SERVER_ADMIN parameter in the Apache server configuration file. If the script is running on a virtual host, this value is that of that virtual host.
SERVER_PORT: The port used by the web server. The default is 80. If using SSL secure connection, this value is the HTTP port set by the user.
SERVER_SIGNATURE: A string containing the server version and virtual machine host name.
PATH_TRANSLATED: The base path of the file system (not the document root directory) where the current script is located. This is the result of a virtual to real path image of the server.
SCRIPT_NAME: Contains the path of the current script.
REQUEST_URI: URI is used to specify the page to be accessed.
PHP_AUTH_DIGEST: When running as an Apache module, during the HTTP Digest authentication process, the change amount is set to the "Authorization" HTTP header content sent by the client.
## PHP_AUTH_USER: When PHP is running under the Apache or IIS module and is using the HTTP authentication function, the change amount is the user name entered by the user.
PHP_AUTH_PW: When PHP is running under the Apache or IIS module and is using the HTTP authentication function, the change amount is the password entered by the user.
AUTH_TYPE: When PHP is running in Apache module mode and is using the HTTP authentication function, the variable is the type of authentication.
PATH_INFO: Contains the path information provided by the client, following the real script name and before the query statement (if it exists).
ORIG_PATH_INFO: The original version of "PATH_INFO" before being processed by PHP.
【$_GET】
## HTTP GET variable.
# Array containing variables passed to the current script via URL parameters.
Passed through urldecode(). echo htmlspecialchars($_GET['name']);
【$_POST】
HTTP POST variable.
Array of variables passed to the current script via the HTTP POST method. echo htmlspecialchars($_POST['name']);
【$_FILES】 HTTP file upload variable.
An array of files uploaded to the current script via HTTP POST.
【$_REQUEST】 HTTP
REQUEST variable. By default, it contains an array of $_GET, $_POST, and $_COOKIE.
Set the order of GPC through PHP's variables_order directive or import_request_variables().
【$_SESSION】 Session variable.
【$_ENV】 Environment variables.
An array of variables passed to the current script through the environment. These variables are imported into PHP's global namespace by the PHP parser runtime environment. Many are provided by shells that support PHP running.
【$_COOKIE】 HTTP Cookies.
An array of variables passed to the current script through HTTP Cookies.
【$php_errormsg】 Previous error message.
$php_errormsg contains the latest error messages generated by PHP. Changes are only available in the scope where the error occurred, and require the track_errors configuration item to be turned on (the default is off).
If the user defines an error handling handler (
set_error_handler()) and returns FALSE, $php_errormsg will be set.
【$HTTP_RAW_POST_DATA】 Native POST data. Contains the raw data submitted by POST.
【$http_response_header】
HTTP response header.
Similar to get_header(). When using HTTP wrappers, the mutator will be populated with HTTP response headers. The variable will be created in the local scope.
[$argc]
The number of parameters passed to the script in CLI mode. Only available when register_argc_argv is on.
The script file name is always passed as a parameter to the current script.
[$argv]
Array of parameters passed to the script. Only available when register_argc_argv is on.
The first parameter is always the file name of the current script.
The above is the detailed content of What are the predefined variables in php?. For more information, please follow other related articles on the PHP Chinese website!

php把负数转为正整数的方法:1、使用abs()函数将负数转为正数,使用intval()函数对正数取整,转为正整数,语法“intval(abs($number))”;2、利用“~”位运算符将负数取反加一,语法“~$number + 1”。

实现方法:1、使用“sleep(延迟秒数)”语句,可延迟执行函数若干秒;2、使用“time_nanosleep(延迟秒数,延迟纳秒数)”语句,可延迟执行函数若干秒和纳秒;3、使用“time_sleep_until(time()+7)”语句。

php除以100保留两位小数的方法:1、利用“/”运算符进行除法运算,语法“数值 / 100”;2、使用“number_format(除法结果, 2)”或“sprintf("%.2f",除法结果)”语句进行四舍五入的处理值,并保留两位小数。

判断方法:1、使用“strtotime("年-月-日")”语句将给定的年月日转换为时间戳格式;2、用“date("z",时间戳)+1”语句计算指定时间戳是一年的第几天。date()返回的天数是从0开始计算的,因此真实天数需要在此基础上加1。

php判断有没有小数点的方法:1、使用“strpos(数字字符串,'.')”语法,如果返回小数点在字符串中第一次出现的位置,则有小数点;2、使用“strrpos(数字字符串,'.')”语句,如果返回小数点在字符串中最后一次出现的位置,则有。

方法:1、用“str_replace(" ","其他字符",$str)”语句,可将nbsp符替换为其他字符;2、用“preg_replace("/(\s|\ \;||\xc2\xa0)/","其他字符",$str)”语句。

在PHP中,可以利用implode()函数的第一个参数来设置没有分隔符,该函数的第一个参数用于规定数组元素之间放置的内容,默认是空字符串,也可将第一个参数设置为空,语法为“implode(数组)”或者“implode("",数组)”。

php字符串有下标。在PHP中,下标不仅可以应用于数组和对象,还可应用于字符串,利用字符串的下标和中括号“[]”可以访问指定索引位置的字符,并对该字符进行读写,语法“字符串名[下标值]”;字符串的下标值(索引值)只能是整数类型,起始值为0。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SublimeText3 Chinese version
Chinese version, very easy to use

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Dreamweaver Mac version
Visual web development tools
