summaryrefslogtreecommitdiff
path: root/ext/standard/tests/strings/parse_str_basic1.phpt
blob: d72fb2624cd136e8f9c9c197a7c91a9c9b483857 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
--TEST--
Test parse_str() function : basic functionality 
--FILE--
<?php

/* Prototype  : void parse_str  ( string $str  [, array &$arr  ] )
 * Description: Parses the string into variables
 * Source code: ext/standard/string.c
*/

echo "*** Testing parse_str() : basic functionality ***\n";

echo "Basic test WITHOUT result arg\n";
$s1 = "first=val1&second=val2&third=val3";
var_dump(parse_str($s1));
var_dump($first, $second, $third);

echo "\nBasic test WITH undefined var for result arg\n";
$s1 = "first=val1&second=val2&third=val3";
var_dump(parse_str($s1, $res1));
var_dump($res1);

echo "\nBasic test WITH existing non-array var for result arg\n";
$res2 =99;
$s1 = "first=val1&second=val2&third=val3";
var_dump(parse_str($s1, $res2));
var_dump($res2);

echo "\nBasic test with an existing array as results array\n";
$res3_array = array(1,2,3,4);
var_dump(parse_str($s1, $res3_array));
var_dump($res3_array);

?>
===DONE===
--EXPECTF--
*** Testing parse_str() : basic functionality ***
Basic test WITHOUT result arg

Deprecated: parse_str(): Calling parse_str() without the result argument is deprecated in %s on line %d
NULL
string(4) "val1"
string(4) "val2"
string(4) "val3"

Basic test WITH undefined var for result arg
NULL
array(3) {
  ["first"]=>
  string(4) "val1"
  ["second"]=>
  string(4) "val2"
  ["third"]=>
  string(4) "val3"
}

Basic test WITH existing non-array var for result arg
NULL
array(3) {
  ["first"]=>
  string(4) "val1"
  ["second"]=>
  string(4) "val2"
  ["third"]=>
  string(4) "val3"
}

Basic test with an existing array as results array
NULL
array(3) {
  ["first"]=>
  string(4) "val1"
  ["second"]=>
  string(4) "val2"
  ["third"]=>
  string(4) "val3"
}
===DONE===