PHPサーバ変数「$_SERVER」の出力方法

PHPのサーバ変数「$_SERVER」に現在何が格納されているかを確認したい場合は、以下のようにすればよい。

《PHPサーバ変数「$_SERVER」を出力する例》
<?php
print_r($_SERVER);
?>

《上記プログラムの実行結果》
Array
(
[HTTP_ACCEPT] => image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/msword, application/x-silverlight, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, */*
[HTTP_ACCEPT_LANGUAGE] => ja
[HTTP_USER_AGENT] => Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; EasyBits GO v1.0; .NET CLR 1.1.4322; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 2.0.50727)
[HTTP_ACCEPT_ENCODING] => gzip, deflate
[HTTP_HOST] => neko
[HTTP_CONNECTION] => Keep-Alive
[PATH] => C:\Program Files\PHP\;%JAVA_HOME%bin;C:\Perl\bin\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Common Files\Ulead Systems\MPEG;C:\Program Files\ATI Technologies\ATI Control Panel;C:\Program Files\PostgreSQL\8.4\bin;C:\Program Files\QuickTime\QTSystem\
[SystemRoot] => C:\WINDOWS
[COMSPEC] => C:\WINDOWS\system32\cmd.exe
[PATHEXT] => .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
[WINDIR] => C:\WINDOWS
[SERVER_SIGNATURE] =>
[SERVER_SOFTWARE] => Apache/2.2.3 (Win32) PHP/5.2.0
[SERVER_NAME] => neko
[SERVER_ADDR] => 192.168.0.3
[SERVER_PORT] => 80
[REMOTE_ADDR] => 192.168.0.3
[DOCUMENT_ROOT] => C:/Program Files/Apache Software Foundation/Apache2.2/htdocs
[SERVER_ADMIN] => test@nobuneko.com
[SCRIPT_FILENAME] => C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/php/server.php
[REMOTE_PORT] => 2744
[GATEWAY_INTERFACE] => CGI/1.1
[SERVER_PROTOCOL] => HTTP/1.1
[REQUEST_METHOD] => GET
[QUERY_STRING] =>
[REQUEST_URI] => /php/server.php
[SCRIPT_NAME] => /php/server.php
[PHP_SELF] => /php/server.php
[REQUEST_TIME] => 1312993720
)

前へ

PHPで定義されている関数一覧を表示する方法

次へ

PHP関数「similar_text」で文字列の類似性を計算できる...かも!?