1<?php 2 $test = isset($_GET['test']) ? $_GET['test'] : null; 3 switch($test) { 4 case 'post': 5 var_dump($_POST); 6 break; 7 case 'input': 8 var_dump(file_get_contents('php://input')); 9 break; 10 case 'getpost': 11 var_dump($_GET); 12 var_dump($_POST); 13 break; 14 case 'referer': 15 echo $_SERVER['HTTP_REFERER']; 16 break; 17 case 'useragent': 18 echo $_SERVER['HTTP_USER_AGENT']; 19 break; 20 case 'httpversion': 21 echo $_SERVER['SERVER_PROTOCOL']; 22 break; 23 case 'cookie': 24 echo $_COOKIE['foo']; 25 break; 26 case 'encoding': 27 echo $_SERVER['HTTP_ACCEPT_ENCODING']; 28 break; 29 case 'contenttype': 30 header('Content-Type: text/plain;charset=utf-8'); 31 break; 32 case 'file': 33 if (isset($_FILES['file'])) { 34 echo $_FILES['file']['name'] . '|' . $_FILES['file']['type'] . '|' . $_FILES['file']['size']; 35 } 36 break; 37 case 'string_file': 38 if (isset($_FILES['file'])) { 39 if ($_FILES['file']['error'] === UPLOAD_ERR_OK) { 40 echo $_FILES['file']['name'] . '|' . $_FILES['file']['type'] . '|' . md5_file($_FILES['file']['tmp_name']); 41 } else { 42 echo 'error:' . $_FILES['file']['error']; 43 } 44 } 45 break; 46 case 'method': 47 echo $_SERVER['REQUEST_METHOD']; 48 break; 49 default: 50 echo "Hello World!\n"; 51 echo "Hello World!"; 52 break; 53 } 54?> 55