超全局数组
$_SERVER 查看服务器信息
$_GET 获取get提交过来的数据 (1) 表单传值(get 方式 post 方式)(2)a标签传值
$_POST 获取psot提交过来的数据 post提交也就是提交整个表单 表单推荐post传值
$_REQUEST 获取a 或者表单get 或者post传过来的数据
<?php setcookie("name1",123); print_r($_COOKIE); ?> 结果是 Array ( [name1] => 123 )
$_COOKIE 同一个变量在多个页面获取到
$_SESSION 同一个变量在多个页面获取到
<?php $_SESSION["name"]="abc"; print_r($_SESSION); ?> 结果是 Array ( [name] => abc )
<?php
$_SESSION["name1"]="abcdefg";
session_start();
$_SESSION["name"]="abc";
print_r($_SESSION);
?>
执行结果也是一样的
Array ( [name] => abc )
$GLOBALS 相当于把其他的全部都包含了
<?php echo "<pre>"; print_r($GLOBALS); echo "</pre>"; ?> 结果是 Array ( [GLOBALS] => Array *RECURSION* [_ENV] => Array ( [ALLUSERSPROFILE] => C:ProgramData [APPDATA] => C:windowssystem32configsystemprofileAppDataRoaming [CommonProgramFiles] => C:Program Files (x86)Common Files [CommonProgramFiles(x86)] => C:Program Files (x86)Common Files [CommonProgramW6432] => C:Program FilesCommon Files [COMPUTERNAME] => SDY-PC [ComSpec] => C:windowssystem32cmd.exe [configsetroot] => C:windowsConfigSetRoot [FP_NO_HOST_CHECK] => NO [LenovoTestLogFile] => c:prdv10PRELOAD.LOG [LenovoTestPath] => c:prdv10 [lib] => C:Program FilesSQLXML 4.0in [LOCALAPPDATA] => C:windowssystem32configsystemprofileAppDataLocal [NUMBER_OF_PROCESSORS] => 4 [OS] => Windows_NT [Path] => C:Program FilesCommon FilesMicrosoft SharedWindows Live;C:Program Files (x86)Common FilesMicrosoft SharedWindows Live;C:windowssystem32;C:windows;C:windowsSystem32Wbem;C:windowsSystem32WindowsPowerShellv1.0;C:Program Files (x86)Windows LiveShared;C:Program Files (x86)Microsoft SQL Server80ToolsBinn;C:Program Files (x86)Microsoft SQL Server90DTSBinn;C:Program Files (x86)Microsoft SQL Server90Toolsinn;C:Program Files (x86)Microsoft SQL Server90ToolsBinnVSShellCommon7IDE;C:Program Files (x86)Microsoft Visual Studio 8Common7IDEPrivateAssemblies;C:Program Files (x86)Microsoft SQL Server100ToolsBinn;C:Program FilesMicrosoft SQL Server100ToolsBinn;C:Program FilesMicrosoft SQL Server100DTSBinn;C:Program FilesMicrosoftWeb Platform Installer;C:Program Files (x86)Microsoft ASP.NETASP.NET Web Pagesv1.0;C:Program Files (x86)Windows Kits8.0Windows Performance Toolkit;C:Program FilesMicrosoft SQL Server110ToolsBinn;C:Program Files (x86)Microsoft SQL Server100DTSBinn;C:Program Files (x86)Microsoft SQL Server100ToolsBinnVSShellCommon7IDE;C:Program Files (x86)Microsoft Visual Studio 9.0Common7IDEPrivateAssemblies; [PATHEXT] => .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC [PROCESSOR_ARCHITECTURE] => x86 [PROCESSOR_ARCHITEW6432] => AMD64 [PROCESSOR_IDENTIFIER] => Intel64 Family 6 Model 42 Stepping 7, GenuineIntel [PROCESSOR_LEVEL] => 6 [PROCESSOR_REVISION] => 2a07 [ProgramData] => C:ProgramData [ProgramFiles] => C:Program Files (x86) [ProgramFiles(x86)] => C:Program Files (x86) [ProgramW6432] => C:Program Files [PSModulePath] => C:windowssystem32WindowsPowerShellv1.0Modules [PUBLIC] => C:UsersPublic [SystemDrive] => C: [SystemRoot] => C:windows [TEMP] => C:windowsTEMP [TMP] => C:windowsTEMP [USERDOMAIN] => WORKGROUP [USERNAME] => SDY-PC$ [USERPROFILE] => C:windowssystem32configsystemprofile [VS100COMNTOOLS] => C:Program Files (x86)Microsoft Visual Studio 10.0Common7Tools [VS110COMNTOOLS] => D:Program Files (x86)Microsoft Visual Studio 11.0Common7Tools [windir] => C:windows [AP_PARENT_PID] => 1652 ) [HTTP_ENV_VARS] => Array ( [ALLUSERSPROFILE] => C:ProgramData [APPDATA] => C:windowssystem32configsystemprofileAppDataRoaming [CommonProgramFiles] => C:Program Files (x86)Common Files [CommonProgramFiles(x86)] => C:Program Files (x86)Common Files [CommonProgramW6432] => C:Program FilesCommon Files [COMPUTERNAME] => SDY-PC [ComSpec] => C:windowssystem32cmd.exe [configsetroot] => C:windowsConfigSetRoot [FP_NO_HOST_CHECK] => NO [LenovoTestLogFile] => c:prdv10PRELOAD.LOG [LenovoTestPath] => c:prdv10 [lib] => C:Program FilesSQLXML 4.0in [LOCALAPPDATA] => C:windowssystem32configsystemprofileAppDataLocal [NUMBER_OF_PROCESSORS] => 4 [OS] => Windows_NT [Path] => C:Program FilesCommon FilesMicrosoft SharedWindows Live;C:Program Files (x86)Common FilesMicrosoft SharedWindows Live;C:windowssystem32;C:windows;C:windowsSystem32Wbem;C:windowsSystem32WindowsPowerShellv1.0;C:Program Files (x86)Windows LiveShared;C:Program Files (x86)Microsoft SQL Server80ToolsBinn;C:Program Files (x86)Microsoft SQL Server90DTSBinn;C:Program Files (x86)Microsoft SQL Server90Toolsinn;C:Program Files (x86)Microsoft SQL Server90ToolsBinnVSShellCommon7IDE;C:Program Files (x86)Microsoft Visual Studio 8Common7IDEPrivateAssemblies;C:Program Files (x86)Microsoft SQL Server100ToolsBinn;C:Program FilesMicrosoft SQL Server100ToolsBinn;C:Program FilesMicrosoft SQL Server100DTSBinn;C:Program FilesMicrosoftWeb Platform Installer;C:Program Files (x86)Microsoft ASP.NETASP.NET Web Pagesv1.0;C:Program Files (x86)Windows Kits8.0Windows Performance Toolkit;C:Program FilesMicrosoft SQL Server110ToolsBinn;C:Program Files (x86)Microsoft SQL Server100DTSBinn;C:Program Files (x86)Microsoft SQL Server100ToolsBinnVSShellCommon7IDE;C:Program Files (x86)Microsoft Visual Studio 9.0Common7IDEPrivateAssemblies; [PATHEXT] => .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC [PROCESSOR_ARCHITECTURE] => x86 [PROCESSOR_ARCHITEW6432] => AMD64 [PROCESSOR_IDENTIFIER] => Intel64 Family 6 Model 42 Stepping 7, GenuineIntel [PROCESSOR_LEVEL] => 6 [PROCESSOR_REVISION] => 2a07 [ProgramData] => C:ProgramData [ProgramFiles] => C:Program Files (x86) [ProgramFiles(x86)] => C:Program Files (x86) [ProgramW6432] => C:Program Files [PSModulePath] => C:windowssystem32WindowsPowerShellv1.0Modules [PUBLIC] => C:UsersPublic [SystemDrive] => C: [SystemRoot] => C:windows [TEMP] => C:windowsTEMP [TMP] => C:windowsTEMP [USERDOMAIN] => WORKGROUP [USERNAME] => SDY-PC$ [USERPROFILE] => C:windowssystem32configsystemprofile [VS100COMNTOOLS] => C:Program Files (x86)Microsoft Visual Studio 10.0Common7Tools [VS110COMNTOOLS] => D:Program Files (x86)Microsoft Visual Studio 11.0Common7Tools [windir] => C:windows [AP_PARENT_PID] => 1652 ) [ALLUSERSPROFILE] => C:ProgramData [APPDATA] => C:windowssystem32configsystemprofileAppDataRoaming [CommonProgramFiles] => C:Program Files (x86)Common Files [CommonProgramFiles(x86)] => C:Program Files (x86)Common Files [CommonProgramW6432] => C:Program FilesCommon Files [COMPUTERNAME] => SDY-PC [ComSpec] => C:windowssystem32cmd.exe [configsetroot] => C:windowsConfigSetRoot [FP_NO_HOST_CHECK] => NO [LenovoTestLogFile] => c:prdv10PRELOAD.LOG [LenovoTestPath] => c:prdv10 [lib] => C:Program FilesSQLXML 4.0in [LOCALAPPDATA] => C:windowssystem32configsystemprofileAppDataLocal [NUMBER_OF_PROCESSORS] => 4 [OS] => Windows_NT [Path] => C:Program FilesCommon FilesMicrosoft SharedWindows Live;C:Program Files (x86)Common FilesMicrosoft SharedWindows Live;C:windowssystem32;C:windows;C:windowsSystem32Wbem;C:windowsSystem32WindowsPowerShellv1.0;C:Program Files (x86)Windows LiveShared;C:Program Files (x86)Microsoft SQL Server80ToolsBinn;C:Program Files (x86)Microsoft SQL Server90DTSBinn;C:Program Files (x86)Microsoft SQL Server90Toolsinn;C:Program Files (x86)Microsoft SQL Server90ToolsBinnVSShellCommon7IDE;C:Program Files (x86)Microsoft Visual Studio 8Common7IDEPrivateAssemblies;C:Program Files (x86)Microsoft SQL Server100ToolsBinn;C:Program FilesMicrosoft SQL Server100ToolsBinn;C:Program FilesMicrosoft SQL Server100DTSBinn;C:Program FilesMicrosoftWeb Platform Installer;C:Program Files (x86)Microsoft ASP.NETASP.NET Web Pagesv1.0;C:Program Files (x86)Windows Kits8.0Windows Performance Toolkit;C:Program FilesMicrosoft SQL Server110ToolsBinn;C:Program Files (x86)Microsoft SQL Server100DTSBinn;C:Program Files (x86)Microsoft SQL Server100ToolsBinnVSShellCommon7IDE;C:Program Files (x86)Microsoft Visual Studio 9.0Common7IDEPrivateAssemblies; [PATHEXT] => .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC [PROCESSOR_ARCHITECTURE] => x86 [PROCESSOR_ARCHITEW6432] => AMD64 [PROCESSOR_IDENTIFIER] => Intel64 Family 6 Model 42 Stepping 7, GenuineIntel [PROCESSOR_LEVEL] => 6 [PROCESSOR_REVISION] => 2a07 [ProgramData] => C:ProgramData [ProgramFiles] => C:Program Files (x86) [ProgramFiles(x86)] => C:Program Files (x86) [ProgramW6432] => C:Program Files [PSModulePath] => C:windowssystem32WindowsPowerShellv1.0Modules [PUBLIC] => C:UsersPublic [SystemDrive] => C: [SystemRoot] => C:windows [TEMP] => C:windowsTEMP [TMP] => C:windowsTEMP [USERDOMAIN] => WORKGROUP [USERNAME] => SDY-PC$ [USERPROFILE] => C:windowssystem32configsystemprofile [VS100COMNTOOLS] => C:Program Files (x86)Microsoft Visual Studio 10.0Common7Tools [VS110COMNTOOLS] => D:Program Files (x86)Microsoft Visual Studio 11.0Common7Tools [windir] => C:windows [AP_PARENT_PID] => 1652 [name1] => 123 [PHPSESSID] => 4227268905f0006c59e7eb7efd50caeb [HTTP_HOST] => localhost [HTTP_USER_AGENT] => Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0 [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 [HTTP_ACCEPT_LANGUAGE] => zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3 [HTTP_ACCEPT_ENCODING] => gzip, deflate [HTTP_COOKIE] => name1=123; PHPSESSID=4227268905f0006c59e7eb7efd50caeb [HTTP_CONNECTION] => keep-alive [PATH] => C:Program FilesCommon FilesMicrosoft SharedWindows Live;C:Program Files (x86)Common FilesMicrosoft SharedWindows Live;C:windowssystem32;C:windows;C:windowsSystem32Wbem;C:windowsSystem32WindowsPowerShellv1.0;C:Program Files (x86)Windows LiveShared;C:Program Files (x86)Microsoft SQL Server80ToolsBinn;C:Program Files (x86)Microsoft SQL Server90DTSBinn;C:Program Files (x86)Microsoft SQL Server90Toolsinn;C:Program Files (x86)Microsoft SQL Server90ToolsBinnVSShellCommon7IDE;C:Program Files (x86)Microsoft Visual Studio 8Common7IDEPrivateAssemblies;C:Program Files (x86)Microsoft SQL Server100ToolsBinn;C:Program FilesMicrosoft SQL Server100ToolsBinn;C:Program FilesMicrosoft SQL Server100DTSBinn;C:Program FilesMicrosoftWeb Platform Installer;C:Program Files (x86)Microsoft ASP.NETASP.NET Web Pagesv1.0;C:Program Files (x86)Windows Kits8.0Windows Performance Toolkit;C:Program FilesMicrosoft SQL Server110ToolsBinn;C:Program Files (x86)Microsoft SQL Server100DTSBinn;C:Program Files (x86)Microsoft SQL Server100ToolsBinnVSShellCommon7IDE;C:Program Files (x86)Microsoft Visual Studio 9.0Common7IDEPrivateAssemblies; [COMSPEC] => C:windowssystem32cmd.exe [WINDIR] => C:windows [SERVER_SIGNATURE] => Apache/2.2.8 (Win32) PHP/5.2.6 Server at localhost Port 80 [SERVER_SOFTWARE] => Apache/2.2.8 (Win32) PHP/5.2.6 [SERVER_NAME] => localhost [SERVER_ADDR] => 127.0.0.1 [SERVER_PORT] => 80 [REMOTE_ADDR] => 127.0.0.1 [DOCUMENT_ROOT] => C:/AppServ/www [SERVER_ADMIN] => local.webmaster@gmail.com [SCRIPT_FILENAME] => C:/AppServ/www/tijiao/session.php [REMOTE_PORT] => 6485 [GATEWAY_INTERFACE] => CGI/1.1 [SERVER_PROTOCOL] => HTTP/1.1 [REQUEST_METHOD] => GET [QUERY_STRING] => [REQUEST_URI] => /tijiao/session.php [SCRIPT_NAME] => /tijiao/session.php [PHP_SELF] => /tijiao/session.php [REQUEST_TIME] => 1404834588 [argv] => Array ( ) [argc] => 0 [_POST] => Array ( ) [HTTP_POST_VARS] => Array ( ) [_GET] => Array ( ) [HTTP_GET_VARS] => Array ( ) [_COOKIE] => Array ( [name1] => 123 [PHPSESSID] => 4227268905f0006c59e7eb7efd50caeb ) [HTTP_COOKIE_VARS] => Array ( [name1] => 123 [PHPSESSID] => 4227268905f0006c59e7eb7efd50caeb ) [_SERVER] => Array ( [HTTP_HOST] => localhost [HTTP_USER_AGENT] => Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0 [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 [HTTP_ACCEPT_LANGUAGE] => zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3 [HTTP_ACCEPT_ENCODING] => gzip, deflate [HTTP_COOKIE] => name1=123; PHPSESSID=4227268905f0006c59e7eb7efd50caeb [HTTP_CONNECTION] => keep-alive [PATH] => C:Program FilesCommon FilesMicrosoft SharedWindows Live;C:Program Files (x86)Common FilesMicrosoft SharedWindows Live;C:windowssystem32;C:windows;C:windowsSystem32Wbem;C:windowsSystem32WindowsPowerShellv1.0;C:Program Files (x86)Windows LiveShared;C:Program Files (x86)Microsoft SQL Server80ToolsBinn;C:Program Files (x86)Microsoft SQL Server90DTSBinn;C:Program Files (x86)Microsoft SQL Server90Toolsinn;C:Program Files (x86)Microsoft SQL Server90ToolsBinnVSShellCommon7IDE;C:Program Files (x86)Microsoft Visual Studio 8Common7IDEPrivateAssemblies;C:Program Files (x86)Microsoft SQL Server100ToolsBinn;C:Program FilesMicrosoft SQL Server100ToolsBinn;C:Program FilesMicrosoft SQL Server100DTSBinn;C:Program FilesMicrosoftWeb Platform Installer;C:Program Files (x86)Microsoft ASP.NETASP.NET Web Pagesv1.0;C:Program Files (x86)Windows Kits8.0Windows Performance Toolkit;C:Program FilesMicrosoft SQL Server110ToolsBinn;C:Program Files (x86)Microsoft SQL Server100DTSBinn;C:Program Files (x86)Microsoft SQL Server100ToolsBinnVSShellCommon7IDE;C:Program Files (x86)Microsoft Visual Studio 9.0Common7IDEPrivateAssemblies; [SystemRoot] => C:windows [COMSPEC] => C:windowssystem32cmd.exe [PATHEXT] => .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC [WINDIR] => C:windows [SERVER_SIGNATURE] => Apache/2.2.8 (Win32) PHP/5.2.6 Server at localhost Port 80 [SERVER_SOFTWARE] => Apache/2.2.8 (Win32) PHP/5.2.6 [SERVER_NAME] => localhost [SERVER_ADDR] => 127.0.0.1 [SERVER_PORT] => 80 [REMOTE_ADDR] => 127.0.0.1 [DOCUMENT_ROOT] => C:/AppServ/www [SERVER_ADMIN] => local.webmaster@gmail.com [SCRIPT_FILENAME] => C:/AppServ/www/tijiao/session.php [REMOTE_PORT] => 6485 [GATEWAY_INTERFACE] => CGI/1.1 [SERVER_PROTOCOL] => HTTP/1.1 [REQUEST_METHOD] => GET [QUERY_STRING] => [REQUEST_URI] => /tijiao/session.php [SCRIPT_NAME] => /tijiao/session.php [PHP_SELF] => /tijiao/session.php [REQUEST_TIME] => 1404834588 [argv] => Array ( ) [argc] => 0 ) [HTTP_SERVER_VARS] => Array ( [HTTP_HOST] => localhost [HTTP_USER_AGENT] => Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0 [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 [HTTP_ACCEPT_LANGUAGE] => zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3 [HTTP_ACCEPT_ENCODING] => gzip, deflate [HTTP_COOKIE] => name1=123; PHPSESSID=4227268905f0006c59e7eb7efd50caeb [HTTP_CONNECTION] => keep-alive [PATH] => C:Program FilesCommon FilesMicrosoft SharedWindows Live;C:Program Files (x86)Common FilesMicrosoft SharedWindows Live;C:windowssystem32;C:windows;C:windowsSystem32Wbem;C:windowsSystem32WindowsPowerShellv1.0;C:Program Files (x86)Windows LiveShared;C:Program Files (x86)Microsoft SQL Server80ToolsBinn;C:Program Files (x86)Microsoft SQL Server90DTSBinn;C:Program Files (x86)Microsoft SQL Server90Toolsinn;C:Program Files (x86)Microsoft SQL Server90ToolsBinnVSShellCommon7IDE;C:Program Files (x86)Microsoft Visual Studio 8Common7IDEPrivateAssemblies;C:Program Files (x86)Microsoft SQL Server100ToolsBinn;C:Program FilesMicrosoft SQL Server100ToolsBinn;C:Program FilesMicrosoft SQL Server100DTSBinn;C:Program FilesMicrosoftWeb Platform Installer;C:Program Files (x86)Microsoft ASP.NETASP.NET Web Pagesv1.0;C:Program Files (x86)Windows Kits8.0Windows Performance Toolkit;C:Program FilesMicrosoft SQL Server110ToolsBinn;C:Program Files (x86)Microsoft SQL Server100DTSBinn;C:Program Files (x86)Microsoft SQL Server100ToolsBinnVSShellCommon7IDE;C:Program Files (x86)Microsoft Visual Studio 9.0Common7IDEPrivateAssemblies; [SystemRoot] => C:windows [COMSPEC] => C:windowssystem32cmd.exe [PATHEXT] => .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC [WINDIR] => C:windows [SERVER_SIGNATURE] => Apache/2.2.8 (Win32) PHP/5.2.6 Server at localhost Port 80 [SERVER_SOFTWARE] => Apache/2.2.8 (Win32) PHP/5.2.6 [SERVER_NAME] => localhost [SERVER_ADDR] => 127.0.0.1 [SERVER_PORT] => 80 [REMOTE_ADDR] => 127.0.0.1 [DOCUMENT_ROOT] => C:/AppServ/www [SERVER_ADMIN] => local.webmaster@gmail.com [SCRIPT_FILENAME] => C:/AppServ/www/tijiao/session.php [REMOTE_PORT] => 6485 [GATEWAY_INTERFACE] => CGI/1.1 [SERVER_PROTOCOL] => HTTP/1.1 [REQUEST_METHOD] => GET [QUERY_STRING] => [REQUEST_URI] => /tijiao/session.php [SCRIPT_NAME] => /tijiao/session.php [PHP_SELF] => /tijiao/session.php [REQUEST_TIME] => 1404834588 [argv] => Array ( ) [argc] => 0 ) [_FILES] => Array ( ) [HTTP_POST_FILES] => Array ( ) [_REQUEST] => Array ( [name1] => 123 [PHPSESSID] => 4227268905f0006c59e7eb7efd50caeb ) )
$_FILES 查看上传文件的信息 以数组方式显示
index页面 <html> <head></head> <body> <form action="session.php" method="post" enctype="multipart/form-data"> <input type="file" name="myfile"/> <input type="submit" name="tj" text="提交"/> </form> </body> </html> session页面 <?php echo "<pre>"; print_r($_FILES); echo "</pre>"; ?> 结果提交一个照片后效果如下 Array ( [myfile] => Array ( [name] => 772267_1404227290.jpg [type] => image/jpeg [tmp_name] => C:WindowsTempphp5247.tmp [error] => 0 [size] => 71634 ) )