1.$_SERVER
<?php
$a=$_SERVER;
var_dump($a);
?>
2.$_FILES
<?php
if($_FILES){
echo "<pre>"; print_r($_FILES); echo "<pre>"; if(!empty($_FILES['file1'])){ if($_FILES['file1']['error'] == 0){ $target_file="./upfile/".$_FILES['file1']['name']; move_uploaded_file($_FILES['file1']['tmp_name'], $target_file); } } } ?> <html> <body> <form action='' method='post' enctype='multipart/form-data'> <input type='file' name='file1'> <input type='submit' value='提交'/> </form> </body> </html>
3.$_GET,$_POST,$_REQUEST
4.$http_response_header
<?php
function get_contents() { file_get_contents("http://example.com"); var_dump($http_response_header); } get_contents(); var_dump($http_response_header); ?>
当使用HTTP包装器http://,https://时,$http_response_header将会被http响应头填充
5.$_COOKIE
<?php
$value = 'something from somewhere';
setcookie("TestCookie", $value);
var_dump($_COOKIE['TestCookie']); ?>