欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

PHP学习:预定义变量详情

程序员文章站 2022-05-15 13:48:20
超全局变量 超全局变量–超全局变量是全部作用域中始终可用的内置变量 $globals 1一个包含了全部变量的全局组合数组。变量的名字就是数组的键。 func...
超全局变量

超全局变量–超全局变量是全部作用域中始终可用的内置变量

$globals

1一个包含了全部变量的全局组合数组。变量的名字就是数组的键。

function test() {

$foo = "local variable";

echo '$foo in global scope: ' . $globals["foo"] . "\n";

echo '$foo in current scope: ' . $foo . "\n";

}

$foo = "example content";

test();

?>

以上例程的输出类似于:

$foo in global scope: example content

$foo in current scope: local variable

$_server

echo "

";


var_dump($_server);

output:

array (size=35)

'http_host' => string 'localhost' (length=9)

'http_connection' => string 'keep-alive' (length=10)

'http_upgrade_insecure_requests' => string '1' (length=1)

'http_user_agent' => string 'mozilla/5.0 (windows nt 10.0; wow64) applewebkit/537.36 (khtml, like gecko) chrome/53.0.2785.104 safari/537.36 core/1.53.3538.400 qqbrowser/9.6.12501.400' (length=153)

'http_accept' => string 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' (length=74)

'http_referer' => string 'https://localhost/test/' (length=22)

'http_accept_encoding' => string 'gzip, deflate, sdch' (length=19)

'http_accept_language' => string 'zh-cn,zh;q=0.8' (length=14)

'path' => string '%appcan_path%;d:\work\python2.7\;d:\work\python2.7\scripts;c:\programdata\oracle\java\javapath;c:\windows\system32;c:\windows;c:\windows\system32\wbem;c:\windows\system32\windowspowershell\v1.0\;d:\wampserver\mysql\bin;d:\work\java\tomcat\bin;d:\work\mozilla firefox\firefox.exe;d:\work\phantomjs\bin;d:\work\chormedriver;c:\windows\system32\config\systemprofile\.dnx\bin;c:\program files\microsoft dnx\dnvm\;c:\program files\microsoft sql server\130\tools\binn\;d:\wampserver\php;c:\programdata\composersetup\bi'... (length=607)

'systemroot' => string 'c:\windows' (length=10)

'comspec' => string 'c:\windows\system32\cmd.exe' (length=27)

'pathext' => string '.com;.exe;.bat;.cmd;.vbs;.vbe;.js;.jse;.wsf;.wsh;.msc' (length=53)

'windir' => string 'c:\windows' (length=10)

'server_signature' => string '' (length=0)

'server_software' => string 'apache/2.4.18 (win64) openssl/1.0.2g php/5.6.19' (length=47)

'server_name' => string 'localhost' (length=9)

'server_addr' => string '::1' (length=3)

'server_port' => string '80' (length=2)

'remote_addr' => string '::1' (length=3)

'document_root' => string 'd:/wampserver/www' (length=17)

'request_scheme' => string 'http' (length=4)

'context_prefix' => string '' (length=0)

'context_document_root' => string 'd:/wampserver/www' (length=17)

'server_admin' => string 'admin@example.com' (length=17)

'script_filename' => string 'd:/wampserver/www/test/$_server.php' (length=35)

'remote_port' => string '57305' (length=5)

'gateway_interface' => string 'cgi/1.1' (length=7)

'server_protocol' => string 'http/1.1' (length=8)

'request_method' => string 'get' (length=3)

'query_string' => string '' (length=0)

'request_uri' => string '/test/$_server.php' (length=18)

'script_name' => string '/test/$_server.php' (length=18)

'php_self' => string '/test/$_server.php' (length=18)

'request_time_float' => float 1510122616.201

'request_time' => int 1510122616