PHP——超全局变量_学习笔记 php application 全局变量 php 全局静态变量 php全局变量赋
程序员文章站
2022-06-12 12:35:13
...
什么是超全局变量
PHP 中的许多预定义变量都是“超全局的”,这意味着它们在一个脚本的全部作用域中都可用。在函数或方法中无需执行 global $variable; 就可以访问它们。
$_SERVER//查看服务器信息$_GET//地址栏参数$_POST//表单提交的值$_REQUEST//接受$_GET或$_POST的值$_FILES//文件上传$_COOKIE//跟踪用户状态$_SESSION//跟踪用户状态$GLOBALS//获取所有全局变量的值
$_SERVER:
可以查看服务器的信息,里面保存关于报头、路径和脚本位置的信息。
下面打印出来看下:
print_r($_SERVER);
?>
结果如下:
Array
(
[HTTP_HOST] => localhost
[HTTP_CONNECTION] => keep-alive
[HTTP_CACHE_CONTROL] => max-age=0
[HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
[HTTP_UPGRADE_INSECURE_REQUESTS] =>1
[HTTP_USER_AGENT] => Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 UBrowser/5.6.11466.7 Safari/537.36
[HTTP_REFERER] =>http://localhost/PHP/php7/
[HTTP_ACCEPT_ENCODING] => gzip, deflate
[HTTP_ACCEPT_LANGUAGE] => zh-CN,zh;q=0.8
[PATH] =>C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;
[SystemRoot] =>C:\Windows
[COMSPEC] =>C:\Windows\system32\cmd.exe
[PATHEXT] => .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
[WINDIR] =>C:\Windows
[SERVER_SIGNATURE] => Apache/2.4.9 (Win64) PHP/5.5.12 Server at localhost Port 80
[SERVER_SOFTWARE] => Apache/2.4.9 (Win64) PHP/5.5.12
[SERVER_NAME] => localhost
[SERVER_ADDR] => ::1
[SERVER_PORT] =>80
[REMOTE_ADDR] => ::1
[DOCUMENT_ROOT] =>D:/www/
[REQUEST_SCHEME] => http
[CONTEXT_PREFIX] => [CONTEXT_DOCUMENT_ROOT] =>D:/www/
[SERVER_ADMIN] => admin@example.com
[SCRIPT_FILENAME] =>D:/www/PHP/php7/demo.php
[REMOTE_PORT] =>52683
[GATEWAY_INTERFACE] => CGI/1.1
[SERVER_PROTOCOL] => HTTP/1.1
[REQUEST_METHOD] => GET
[QUERY_STRING] => [REQUEST_URI] => /PHP/php7/demo.php
[SCRIPT_NAME] => /PHP/php7/demo.php
[PHP_SELF] => /PHP/php7/demo.php
[REQUEST_TIME_FLOAT] =>1460548562.994
[REQUEST_TIME] =>1460548562
)
').addClass('pre-numbering').hide();
$(this).addClass('has-numbering').parent().append($numbering);
for (i = 1; i ').text(i));
};
$numbering.fadeIn(1700);
});
});
以上就介绍了PHP——超全局变量_学习笔记,包括了全局变量,php方面的内容,希望对PHP教程有兴趣的朋友有所帮助。