PHP  
 PHP_HEAD
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

Test Failure Report for ext/curl/tests/curl_file_upload.phpt ('CURL file uploading')

Script

1: <?php
2:
3:
function testcurl($ch$name$mime ''$postname '')
4: {
5:     if(!empty(
$postname)) {
6:         
$file = new CurlFile($name$mime$postname);
7:     } else if(!empty(
$mime)) {
8:         
$file = new CurlFile($name$mime);
9:     } else {
10:         
$file = new CurlFile($name);
11:     }
12:     
curl_setopt($chCURLOPT_POSTFIELDS, array("file" => $file));
13:     
var_dump(curl_exec($ch));
14: }
15:
16: include 
'server.inc';
17:
$host curl_cli_server_start();
18:
$ch curl_init();
19:
curl_setopt($chCURLOPT_URL"{$host}/get.inc?test=file");
20:
curl_setopt($chCURLOPT_RETURNTRANSFER1);
21:
22:
testcurl($ch__DIR__ '/curl_testdata1.txt');
23:
testcurl($ch__DIR__ '/curl_testdata1.txt''text/plain');
24:
testcurl($ch__DIR__ '/curl_testdata1.txt''''foo.txt');
25:
testcurl($ch__DIR__ '/curl_testdata1.txt''text/plain''foo.txt');
26:
27:
$file = new CurlFile(__DIR__ '/curl_testdata1.txt');
28:
$file->setMimeType('text/plain');
29:
var_dump($file->getMimeType());
30:
var_dump($file->getFilename());
31:
curl_setopt($chCURLOPT_POSTFIELDS, array("file" => $file));
32:
var_dump(curl_exec($ch));
33:
34:
$file curl_file_create(__DIR__ '/curl_testdata1.txt');
35:
$file->setPostFilename('foo.txt');
36:
var_dump($file->getPostFilename());
37:
curl_setopt($chCURLOPT_POSTFIELDS, array("file" => $file));
38:
var_dump(curl_exec($ch));
39:
40:
curl_setopt($chCURLOPT_SAFE_UPLOAD0);
41:
$params = array('file' => '@' __DIR__ '/curl_testdata1.txt');
42:
curl_setopt($chCURLOPT_POSTFIELDS$params);
43:
var_dump(curl_exec($ch));
44:
45:
curl_setopt($chCURLOPT_SAFE_UPLOADtrue);
46:
$params = array('file' => '@' __DIR__ '/curl_testdata1.txt');
47:
curl_setopt($chCURLOPT_POSTFIELDS$params);
48:
var_dump(curl_exec($ch));
49:
50:
curl_setopt($chCURLOPT_URL"{$host}/get.inc?test=post");
51:
$params = array('file' => '@' __DIR__ '/curl_testdata1.txt');
52:
curl_setopt($chCURLOPT_POSTFIELDS$params);
53:
var_dump(curl_exec($ch));
54:
55:
curl_close($ch);
56:
?>
57:

Expected

string(%d) "curl_testdata1.txt|application/octet-stream"
string(%d) "curl_testdata1.txt|text/plain"
string(%d) "foo.txt|application/octet-stream"
string(%d) "foo.txt|text/plain"
string(%d) "text/plain"
string(%d) "%s/curl_testdata1.txt"
string(%d) "curl_testdata1.txt|text/plain"
string(%d) "foo.txt"
string(%d) "foo.txt|application/octet-stream"

Warning: curl_setopt(): Disabling safe uploads is no longer supported in %s on line %d
string(0) ""
string(0) ""
string(%d) "array(1) {
  ["file"]=>
  string(%d) "@%s/curl_testdata1.txt"
}
"

Output

string(973) "<?php
  $test = isset($_GET['test']) ? $_GET['test'] : null;
  switch($test) {
    case 'post':
      var_dump($_POST);
      break;
    case 'getpost':
      var_dump($_GET);
      var_dump($_POST);
      break;
    case 'referer':
      echo $_SERVER['HTTP_REFERER'];
      break;
    case 'useragent':
      echo $_SERVER['HTTP_USER_AGENT'];
      break;
    case 'httpversion':
      echo $_SERVER['SERVER_PROTOCOL'];
      break;
    case 'cookie':
      echo $_COOKIE['foo'];
      break;
    case 'encoding':
      echo $_SERVER['HTTP_ACCEPT_ENCODING'];
      break;
    case 'contenttype':
      header('Content-Type: text/plain;charset=utf-8');
      break;
    case 'file':
      if (isset($_FILES['file'])) {
          echo $_FILES['file']['name'] . '|' . $_FILES['file']['type'];
      }
      break;
    case 'method':
      echo $_SERVER['REQUEST_METHOD'];
      break;
    default:
      echo "Hello World!\n";
      echo "Hello World!";
      break;
  }
?>
"
string(973) "<?php
  $test = isset($_GET['test']) ? $_GET['test'] : null;
  switch($test) {
    case 'post':
      var_dump($_POST);
      break;
    case 'getpost':
      var_dump($_GET);
      var_dump($_POST);
      break;
    case 'referer':
      echo $_SERVER['HTTP_REFERER'];
      break;
    case 'useragent':
      echo $_SERVER['HTTP_USER_AGENT'];
      break;
    case 'httpversion':
      echo $_SERVER['SERVER_PROTOCOL'];
      break;
    case 'cookie':
      echo $_COOKIE['foo'];
      break;
    case 'encoding':
      echo $_SERVER['HTTP_ACCEPT_ENCODING'];
      break;
    case 'contenttype':
      header('Content-Type: text/plain;charset=utf-8');
      break;
    case 'file':
      if (isset($_FILES['file'])) {
          echo $_FILES['file']['name'] . '|' . $_FILES['file']['type'];
      }
      break;
    case 'method':
      echo $_SERVER['REQUEST_METHOD'];
      break;
    default:
      echo "Hello World!\n";
      echo "Hello World!";
      break;
  }
?>
"
string(973) "<?php
  $test = isset($_GET['test']) ? $_GET['test'] : null;
  switch($test) {
    case 'post':
      var_dump($_POST);
      break;
    case 'getpost':
      var_dump($_GET);
      var_dump($_POST);
      break;
    case 'referer':
      echo $_SERVER['HTTP_REFERER'];
      break;
    case 'useragent':
      echo $_SERVER['HTTP_USER_AGENT'];
      break;
    case 'httpversion':
      echo $_SERVER['SERVER_PROTOCOL'];
      break;
    case 'cookie':
      echo $_COOKIE['foo'];
      break;
    case 'encoding':
      echo $_SERVER['HTTP_ACCEPT_ENCODING'];
      break;
    case 'contenttype':
      header('Content-Type: text/plain;charset=utf-8');
      break;
    case 'file':
      if (isset($_FILES['file'])) {
          echo $_FILES['file']['name'] . '|' . $_FILES['file']['type'];
      }
      break;
    case 'method':
      echo $_SERVER['REQUEST_METHOD'];
      break;
    default:
      echo "Hello World!\n";
      echo "Hello World!";
      break;
  }
?>
"
string(973) "<?php
  $test = isset($_GET['test']) ? $_GET['test'] : null;
  switch($test) {
    case 'post':
      var_dump($_POST);
      break;
    case 'getpost':
      var_dump($_GET);
      var_dump($_POST);
      break;
    case 'referer':
      echo $_SERVER['HTTP_REFERER'];
      break;
    case 'useragent':
      echo $_SERVER['HTTP_USER_AGENT'];
      break;
    case 'httpversion':
      echo $_SERVER['SERVER_PROTOCOL'];
      break;
    case 'cookie':
      echo $_COOKIE['foo'];
      break;
    case 'encoding':
      echo $_SERVER['HTTP_ACCEPT_ENCODING'];
      break;
    case 'contenttype':
      header('Content-Type: text/plain;charset=utf-8');
      break;
    case 'file':
      if (isset($_FILES['file'])) {
          echo $_FILES['file']['name'] . '|' . $_FILES['file']['type'];
      }
      break;
    case 'method':
      echo $_SERVER['REQUEST_METHOD'];
      break;
    default:
      echo "Hello World!\n";
      echo "Hello World!";
      break;
  }
?>
"
string(10) "text/plain"
string(56) "/var/php_gcov/PHP_HEAD/ext/curl/tests/curl_testdata1.txt"
string(973) "<?php
  $test = isset($_GET['test']) ? $_GET['test'] : null;
  switch($test) {
    case 'post':
      var_dump($_POST);
      break;
    case 'getpost':
      var_dump($_GET);
      var_dump($_POST);
      break;
    case 'referer':
      echo $_SERVER['HTTP_REFERER'];
      break;
    case 'useragent':
      echo $_SERVER['HTTP_USER_AGENT'];
      break;
    case 'httpversion':
      echo $_SERVER['SERVER_PROTOCOL'];
      break;
    case 'cookie':
      echo $_COOKIE['foo'];
      break;
    case 'encoding':
      echo $_SERVER['HTTP_ACCEPT_ENCODING'];
      break;
    case 'contenttype':
      header('Content-Type: text/plain;charset=utf-8');
      break;
    case 'file':
      if (isset($_FILES['file'])) {
          echo $_FILES['file']['name'] . '|' . $_FILES['file']['type'];
      }
      break;
    case 'method':
      echo $_SERVER['REQUEST_METHOD'];
      break;
    default:
      echo "Hello World!\n";
      echo "Hello World!";
      break;
  }
?>
"
string(7) "foo.txt"
string(973) "<?php
  $test = isset($_GET['test']) ? $_GET['test'] : null;
  switch($test) {
    case 'post':
      var_dump($_POST);
      break;
    case 'getpost':
      var_dump($_GET);
      var_dump($_POST);
      break;
    case 'referer':
      echo $_SERVER['HTTP_REFERER'];
      break;
    case 'useragent':
      echo $_SERVER['HTTP_USER_AGENT'];
      break;
    case 'httpversion':
      echo $_SERVER['SERVER_PROTOCOL'];
      break;
    case 'cookie':
      echo $_COOKIE['foo'];
      break;
    case 'encoding':
      echo $_SERVER['HTTP_ACCEPT_ENCODING'];
      break;
    case 'contenttype':
      header('Content-Type: text/plain;charset=utf-8');
      break;
    case 'file':
      if (isset($_FILES['file'])) {
          echo $_FILES['file']['name'] . '|' . $_FILES['file']['type'];
      }
      break;
    case 'method':
      echo $_SERVER['REQUEST_METHOD'];
      break;
    default:
      echo "Hello World!\n";
      echo "Hello World!";
      break;
  }
?>
"

Warning: curl_setopt(): Disabling safe uploads is no longer supported in /var/php_gcov/PHP_HEAD/ext/curl/tests/curl_file_upload.php on line 40
string(973) "<?php
  $test = isset($_GET['test']) ? $_GET['test'] : null;
  switch($test) {
    case 'post':
      var_dump($_POST);
      break;
    case 'getpost':
      var_dump($_GET);
      var_dump($_POST);
      break;
    case 'referer':
      echo $_SERVER['HTTP_REFERER'];
      break;
    case 'useragent':
      echo $_SERVER['HTTP_USER_AGENT'];
      break;
    case 'httpversion':
      echo $_SERVER['SERVER_PROTOCOL'];
      break;
    case 'cookie':
      echo $_COOKIE['foo'];
      break;
    case 'encoding':
      echo $_SERVER['HTTP_ACCEPT_ENCODING'];
      break;
    case 'contenttype':
      header('Content-Type: text/plain;charset=utf-8');
      break;
    case 'file':
      if (isset($_FILES['file'])) {
          echo $_FILES['file']['name'] . '|' . $_FILES['file']['type'];
      }
      break;
    case 'method':
      echo $_SERVER['REQUEST_METHOD'];
      break;
    default:
      echo "Hello World!\n";
      echo "Hello World!";
      break;
  }
?>
"
string(973) "<?php
  $test = isset($_GET['test']) ? $_GET['test'] : null;
  switch($test) {
    case 'post':
      var_dump($_POST);
      break;
    case 'getpost':
      var_dump($_GET);
      var_dump($_POST);
      break;
    case 'referer':
      echo $_SERVER['HTTP_REFERER'];
      break;
    case 'useragent':
      echo $_SERVER['HTTP_USER_AGENT'];
      break;
    case 'httpversion':
      echo $_SERVER['SERVER_PROTOCOL'];
      break;
    case 'cookie':
      echo $_COOKIE['foo'];
      break;
    case 'encoding':
      echo $_SERVER['HTTP_ACCEPT_ENCODING'];
      break;
    case 'contenttype':
      header('Content-Type: text/plain;charset=utf-8');
      break;
    case 'file':
      if (isset($_FILES['file'])) {
          echo $_FILES['file']['name'] . '|' . $_FILES['file']['type'];
      }
      break;
    case 'method':
      echo $_SERVER['REQUEST_METHOD'];
      break;
    default:
      echo "Hello World!\n";
      echo "Hello World!";
      break;
  }
?>
"
string(973) "<?php
  $test = isset($_GET['test']) ? $_GET['test'] : null;
  switch($test) {
    case 'post':
      var_dump($_POST);
      break;
    case 'getpost':
      var_dump($_GET);
      var_dump($_POST);
      break;
    case 'referer':
      echo $_SERVER['HTTP_REFERER'];
      break;
    case 'useragent':
      echo $_SERVER['HTTP_USER_AGENT'];
      break;
    case 'httpversion':
      echo $_SERVER['SERVER_PROTOCOL'];
      break;
    case 'cookie':
      echo $_COOKIE['foo'];
      break;
    case 'encoding':
      echo $_SERVER['HTTP_ACCEPT_ENCODING'];
      break;
    case 'contenttype':
      header('Content-Type: text/plain;charset=utf-8');
      break;
    case 'file':
      if (isset($_FILES['file'])) {
          echo $_FILES['file']['name'] . '|' . $_FILES['file']['type'];
      }
      break;
    case 'method':
      echo $_SERVER['REQUEST_METHOD'];
      break;
    default:
      echo "Hello World!\n";
      echo "Hello World!";
      break;
  }
?>
"

Diff

001+ string(973) "<?php
002+   $test = isset($_GET['test']) ? $_GET['test'] : null;
003+   switch($test) {
004+     case 'post':
005+       var_dump($_POST);
006+       break;
007+     case 'getpost':
008+       var_dump($_GET);
009+       var_dump($_POST);
010+       break;
011+     case 'referer':
012+       echo $_SERVER['HTTP_REFERER'];
013+       break;
014+     case 'useragent':
015+       echo $_SERVER['HTTP_USER_AGENT'];
016+       break;
017+     case 'httpversion':
018+       echo $_SERVER['SERVER_PROTOCOL'];
001- string(%d) "curl_testdata1.txt|application/octet-stream"
002- string(%d) "curl_testdata1.txt|text/plain"
003- string(%d) "foo.txt|application/octet-stream"
004- string(%d) "foo.txt|text/plain"
005- string(%d) "text/plain"
006- string(%d) "%s/curl_testdata1.txt"
007- string(%d) "curl_testdata1.txt|text/plain"
008- string(%d) "foo.txt"
009- string(%d) "foo.txt|application/octet-stream"
010- 
011- Warning: curl_setopt(): Disabling safe uploads is no longer supported in %s on line %d
012- string(0) ""
013- string(0) ""
014- string(%d) "array(1) {
015-   ["file"]=>
016-   string(%d) "@%s/curl_testdata1.txt"
017- }
018- "
019+       break;
020+     case 'cookie':
021+       echo $_COOKIE['foo'];
022+       break;
023+     case 'encoding':
024+       echo $_SERVER['HTTP_ACCEPT_ENCODING'];
025+       break;
026+     case 'contenttype':
027+       header('Content-Type: text/plain;charset=utf-8');
028+       break;
029+     case 'file':
030+       if (isset($_FILES['file'])) {
031+           echo $_FILES['file']['name'] . '|' . $_FILES['file']['type'];
032+       }
033+       break;
034+     case 'method':
035+       echo $_SERVER['REQUEST_METHOD'];
036+       break;
037+     default:
038+       echo "Hello World!\n";
039+       echo "Hello World!";
040+       break;
041+   }
042+ ?>
043+ "
044+ string(973) "<?php
045+   $test = isset($_GET['test']) ? $_GET['test'] : null;
046+   switch($test) {
047+     case 'post':
048+       var_dump($_POST);
049+       break;
050+     case 'getpost':
051+       var_dump($_GET);
052+       var_dump($_POST);
053+       break;
054+     case 'referer':
055+       echo $_SERVER['HTTP_REFERER'];
056+       break;
057+     case 'useragent':
058+       echo $_SERVER['HTTP_USER_AGENT'];
059+       break;
060+     case 'httpversion':
061+       echo $_SERVER['SERVER_PROTOCOL'];
062+       break;
063+     case 'cookie':
064+       echo $_COOKIE['foo'];
065+       break;
066+     case 'encoding':
067+       echo $_SERVER['HTTP_ACCEPT_ENCODING'];
068+       break;
069+     case 'contenttype':
070+       header('Content-Type: text/plain;charset=utf-8');
071+       break;
072+     case 'file':
073+       if (isset($_FILES['file'])) {
074+           echo $_FILES['file']['name'] . '|' . $_FILES['file']['type'];
075+       }
076+       break;
077+     case 'method':
078+       echo $_SERVER['REQUEST_METHOD'];
079+       break;
080+     default:
081+       echo "Hello World!\n";
082+       echo "Hello World!";
083+       break;
084+   }
085+ ?>
086+ "
087+ string(973) "<?php
088+   $test = isset($_GET['test']) ? $_GET['test'] : null;
089+   switch($test) {
090+     case 'post':
091+       var_dump($_POST);
092+       break;
093+     case 'getpost':
094+       var_dump($_GET);
095+       var_dump($_POST);
096+       break;
097+     case 'referer':
098+       echo $_SERVER['HTTP_REFERER'];
099+       break;
100+     case 'useragent':
101+       echo $_SERVER['HTTP_USER_AGENT'];
102+       break;
103+     case 'httpversion':
104+       echo $_SERVER['SERVER_PROTOCOL'];
105+       break;
106+     case 'cookie':
107+       echo $_COOKIE['foo'];
108+       break;
109+     case 'encoding':
110+       echo $_SERVER['HTTP_ACCEPT_ENCODING'];
111+       break;
112+     case 'contenttype':
113+       header('Content-Type: text/plain;charset=utf-8');
114+       break;
115+     case 'file':
116+       if (isset($_FILES['file'])) {
117+           echo $_FILES['file']['name'] . '|' . $_FILES['file']['type'];
118+       }
119+       break;
120+     case 'method':
121+       echo $_SERVER['REQUEST_METHOD'];
122+       break;
123+     default:
124+       echo "Hello World!\n";
125+       echo "Hello World!";
126+       break;
127+   }
128+ ?>
129+ "
130+ string(973) "<?php
131+   $test = isset($_GET['test']) ? $_GET['test'] : null;
132+   switch($test) {
133+     case 'post':
134+       var_dump($_POST);
135+       break;
136+     case 'getpost':
137+       var_dump($_GET);
138+       var_dump($_POST);
139+       break;
140+     case 'referer':
141+       echo $_SERVER['HTTP_REFERER'];
142+       break;
143+     case 'useragent':
144+       echo $_SERVER['HTTP_USER_AGENT'];
145+       break;
146+     case 'httpversion':
147+       echo $_SERVER['SERVER_PROTOCOL'];
148+       break;
149+     case 'cookie':
150+       echo $_COOKIE['foo'];
151+       break;
152+     case 'encoding':
153+       echo $_SERVER['HTTP_ACCEPT_ENCODING'];
154+       break;
155+     case 'contenttype':
156+       header('Content-Type: text/plain;charset=utf-8');
157+       break;
158+     case 'file':
159+       if (isset($_FILES['file'])) {
160+           echo $_FILES['file']['name'] . '|' . $_FILES['file']['type'];
161+       }
162+       break;
163+     case 'method':
164+       echo $_SERVER['REQUEST_METHOD'];
165+       break;
166+     default:
167+       echo "Hello World!\n";
168+       echo "Hello World!";
169+       break;
170+   }
171+ ?>
172+ "
173+ string(10) "text/plain"
174+ string(56) "/var/php_gcov/PHP_HEAD/ext/curl/tests/curl_testdata1.txt"
175+ string(973) "<?php
176+   $test = isset($_GET['test']) ? $_GET['test'] : null;
177+   switch($test) {
178+     case 'post':
179+       var_dump($_POST);
180+       break;
181+     case 'getpost':
182+       var_dump($_GET);
183+       var_dump($_POST);
184+       break;
185+     case 'referer':
186+       echo $_SERVER['HTTP_REFERER'];
187+       break;
188+     case 'useragent':
189+       echo $_SERVER['HTTP_USER_AGENT'];
190+       break;
191+     case 'httpversion':
192+       echo $_SERVER['SERVER_PROTOCOL'];
193+       break;
194+     case 'cookie':
195+       echo $_COOKIE['foo'];
196+       break;
197+     case 'encoding':
198+       echo $_SERVER['HTTP_ACCEPT_ENCODING'];
199+       break;
200+     case 'contenttype':
201+       header('Content-Type: text/plain;charset=utf-8');
202+       break;
203+     case 'file':
204+       if (isset($_FILES['file'])) {
205+           echo $_FILES['file']['name'] . '|' . $_FILES['file']['type'];
206+       }
207+       break;
208+     case 'method':
209+       echo $_SERVER['REQUEST_METHOD'];
210+       break;
211+     default:
212+       echo "Hello World!\n";
213+       echo "Hello World!";
214+       break;
215+   }
216+ ?>
217+ "
218+ string(7) "foo.txt"
219+ string(973) "<?php
220+   $test = isset($_GET['test']) ? $_GET['test'] : null;
221+   switch($test) {
222+     case 'post':
223+       var_dump($_POST);
224+       break;
225+     case 'getpost':
226+       var_dump($_GET);
227+       var_dump($_POST);
228+       break;
229+     case 'referer':
230+       echo $_SERVER['HTTP_REFERER'];
231+       break;
232+     case 'useragent':
233+       echo $_SERVER['HTTP_USER_AGENT'];
234+       break;
235+     case 'httpversion':
236+       echo $_SERVER['SERVER_PROTOCOL'];
237+       break;
238+     case 'cookie':
239+       echo $_COOKIE['foo'];
240+       break;
241+     case 'encoding':
242+       echo $_SERVER['HTTP_ACCEPT_ENCODING'];
243+       break;
244+     case 'contenttype':
245+       header('Content-Type: text/plain;charset=utf-8');
246+       break;
247+     case 'file':
248+       if (isset($_FILES['file'])) {
249+           echo $_FILES['file']['name'] . '|' . $_FILES['file']['type'];
250+       }
251+       break;
252+     case 'method':
253+       echo $_SERVER['REQUEST_METHOD'];
254+       break;
255+     default:
256+       echo "Hello World!\n";
257+       echo "Hello World!";
258+       break;
259+   }
260+ ?>
261+ "
262+ 
263+ Warning: curl_setopt(): Disabling safe uploads is no longer supported in /var/php_gcov/PHP_HEAD/ext/curl/tests/curl_file_upload.php on line 40
264+ string(973) "<?php
265+   $test = isset($_GET['test']) ? $_GET['test'] : null;
266+   switch($test) {
267+     case 'post':
268+       var_dump($_POST);
269+       break;
270+     case 'getpost':
271+       var_dump($_GET);
272+       var_dump($_POST);
273+       break;
274+     case 'referer':
275+       echo $_SERVER['HTTP_REFERER'];
276+       break;
277+     case 'useragent':
278+       echo $_SERVER['HTTP_USER_AGENT'];
279+       break;
280+     case 'httpversion':
281+       echo $_SERVER['SERVER_PROTOCOL'];
282+       break;
283+     case 'cookie':
284+       echo $_COOKIE['foo'];
285+       break;
286+     case 'encoding':
287+       echo $_SERVER['HTTP_ACCEPT_ENCODING'];
288+       break;
289+     case 'contenttype':
290+       header('Content-Type: text/plain;charset=utf-8');
291+       break;
292+     case 'file':
293+       if (isset($_FILES['file'])) {
294+           echo $_FILES['file']['name'] . '|' . $_FILES['file']['type'];
295+       }
296+       break;
297+     case 'method':
298+       echo $_SERVER['REQUEST_METHOD'];
299+       break;
300+     default:
301+       echo "Hello World!\n";
302+       echo "Hello World!";
303+       break;
304+   }
305+ ?>
306+ "
307+ string(973) "<?php
308+   $test = isset($_GET['test']) ? $_GET['test'] : null;
309+   switch($test) {
310+     case 'post':
311+       var_dump($_POST);
312+       break;
313+     case 'getpost':
314+       var_dump($_GET);
315+       var_dump($_POST);
316+       break;
317+     case 'referer':
318+       echo $_SERVER['HTTP_REFERER'];
319+       break;
320+     case 'useragent':
321+       echo $_SERVER['HTTP_USER_AGENT'];
322+       break;
323+     case 'httpversion':
324+       echo $_SERVER['SERVER_PROTOCOL'];
325+       break;
326+     case 'cookie':
327+       echo $_COOKIE['foo'];
328+       break;
329+     case 'encoding':
330+       echo $_SERVER['HTTP_ACCEPT_ENCODING'];
331+       break;
332+     case 'contenttype':
333+       header('Content-Type: text/plain;charset=utf-8');
334+       break;
335+     case 'file':
336+       if (isset($_FILES['file'])) {
337+           echo $_FILES['file']['name'] . '|' . $_FILES['file']['type'];
338+       }
339+       break;
340+     case 'method':
341+       echo $_SERVER['REQUEST_METHOD'];
342+       break;
343+     default:
344+       echo "Hello World!\n";
345+       echo "Hello World!";
346+       break;
347+   }
348+ ?>
349+ "
350+ string(973) "<?php
351+   $test = isset($_GET['test']) ? $_GET['test'] : null;
352+   switch($test) {
353+     case 'post':
354+       var_dump($_POST);
355+       break;
356+     case 'getpost':
357+       var_dump($_GET);
358+       var_dump($_POST);
359+       break;
360+     case 'referer':
361+       echo $_SERVER['HTTP_REFERER'];
362+       break;
363+     case 'useragent':
364+       echo $_SERVER['HTTP_USER_AGENT'];
365+       break;
366+     case 'httpversion':
367+       echo $_SERVER['SERVER_PROTOCOL'];
368+       break;
369+     case 'cookie':
370+       echo $_COOKIE['foo'];
371+       break;
372+     case 'encoding':
373+       echo $_SERVER['HTTP_ACCEPT_ENCODING'];
374+       break;
375+     case 'contenttype':
376+       header('Content-Type: text/plain;charset=utf-8');
377+       break;
378+     case 'file':
379+       if (isset($_FILES['file'])) {
380+           echo $_FILES['file']['name'] . '|' . $_FILES['file']['type'];
381+       }
382+       break;
383+     case 'method':
384+       echo $_SERVER['REQUEST_METHOD'];
385+       break;
386+     default:
387+       echo "Hello World!\n";
388+       echo "Hello World!";
389+       break;
390+   }
391+ ?>
392+ "

 

Generated at Mon, 14 Jan 2019 03:56:25 +0000 (4 days ago)

Copyright © 2005-2019 The PHP Group
All rights reserved.