1--TEST-- 2Bug #60180 ($_SERVER["PHP_SELF"] incorrect) 3--SKIPIF-- 4<?php 5if(!file_exists(__DIR__."/../../../../sapi/cli/tests/php_cli_server.inc")) 6 die("skip could not found cli server script"); 7$res = @include __DIR__."/../../../../sapi/cli/tests/php_cli_server.inc"; 8if(!$res) { 9 die("skip could not open cli server script"); 10} 11?> 12--FILE-- 13<?php 14include __DIR__."/../../../../sapi/cli/tests/php_cli_server.inc"; 15php_cli_server_start(file_get_contents(__DIR__.'/bug64433_srv.inc')); 16 17echo file_get_contents("http://".PHP_CLI_SERVER_ADDRESS."/index.php"); 18echo "default\n"; 19$codes = array(200, 201, 204, 301, 302, 303, 304, 305, 307, 404, 500); 20foreach($codes as $code) { 21 echo "$code: ".file_get_contents("http://".PHP_CLI_SERVER_ADDRESS."/index.php?status=$code&loc=1"); 22} 23echo "follow=0\n"; 24$arr = array('http'=> 25 array( 26 'follow_location'=>0, 27 ) 28 ); 29$context = stream_context_create($arr); 30foreach($codes as $code) { 31 echo "$code: ".file_get_contents("http://".PHP_CLI_SERVER_ADDRESS."/index.php?status=$code&loc=1", false, $context); 32} 33echo "follow=1\n"; 34$arr = array('http'=> 35 array( 36 'follow_location'=>1, 37 ) 38 ); 39$context = stream_context_create($arr); 40foreach($codes as $code) { 41 echo "$code: ".file_get_contents("http://".PHP_CLI_SERVER_ADDRESS."/index.php?status=$code&loc=1", false, $context); 42} 43?> 44--EXPECT-- 45HELLO! 46default 47200: HELLO! 48201: HELLO! 49204: HELLO! 50301: REDIRECTED 51302: REDIRECTED 52303: REDIRECTED 53304: HELLO! 54305: HELLO! 55307: REDIRECTED 56404: HELLO! 57500: HELLO! 58follow=0 59200: HELLO! 60201: HELLO! 61204: HELLO! 62301: HELLO! 63302: HELLO! 64303: HELLO! 65304: HELLO! 66305: HELLO! 67307: HELLO! 68404: HELLO! 69500: HELLO! 70follow=1 71200: REDIRECTED 72201: REDIRECTED 73204: REDIRECTED 74301: REDIRECTED 75302: REDIRECTED 76303: REDIRECTED 77304: REDIRECTED 78305: REDIRECTED 79307: REDIRECTED 80404: REDIRECTED 81500: REDIRECTED 82