1--TEST-- 2Test parse_str() function : basic functionality 3--FILE-- 4<?php 5 6/* Prototype : void parse_str ( string $str [, array &$arr ] ) 7 * Description: Parses the string into variables 8 * Source code: ext/standard/string.c 9*/ 10 11echo "*** Testing parse_str() : basic functionality ***\n"; 12 13echo "Basic test WITHOUT result arg\n"; 14$s1 = "first=val1&second=val2&third=val3"; 15var_dump(parse_str($s1)); 16var_dump($first, $second, $third); 17 18echo "\nBasic test WITH undefined var for result arg\n"; 19$s1 = "first=val1&second=val2&third=val3"; 20var_dump(parse_str($s1, $res1)); 21var_dump($res1); 22 23echo "\nBasic test WITH existing non-array var for result arg\n"; 24$res2 =99; 25$s1 = "first=val1&second=val2&third=val3"; 26var_dump(parse_str($s1, $res2)); 27var_dump($res2); 28 29echo "\nBasic test with an existing array as results array\n"; 30$res3_array = array(1,2,3,4); 31var_dump(parse_str($s1, $res3_array)); 32var_dump($res3_array); 33 34?> 35===DONE=== 36--EXPECTF-- 37*** Testing parse_str() : basic functionality *** 38Basic test WITHOUT result arg 39 40Deprecated: parse_str(): Calling parse_str() without the result argument is deprecated in %s on line %d 41NULL 42string(4) "val1" 43string(4) "val2" 44string(4) "val3" 45 46Basic test WITH undefined var for result arg 47NULL 48array(3) { 49 ["first"]=> 50 string(4) "val1" 51 ["second"]=> 52 string(4) "val2" 53 ["third"]=> 54 string(4) "val3" 55} 56 57Basic test WITH existing non-array var for result arg 58NULL 59array(3) { 60 ["first"]=> 61 string(4) "val1" 62 ["second"]=> 63 string(4) "val2" 64 ["third"]=> 65 string(4) "val3" 66} 67 68Basic test with an existing array as results array 69NULL 70array(3) { 71 ["first"]=> 72 string(4) "val1" 73 ["second"]=> 74 string(4) "val2" 75 ["third"]=> 76 string(4) "val3" 77} 78===DONE=== 79