1--TEST--
2Test session_encode() function : basic functionality
3--INI--
4serialize_precision=100
5--EXTENSIONS--
6session
7--SKIPIF--
8<?php include('skipif.inc'); ?>
9--FILE--
10<?php
11
12ob_start();
13
14echo "*** Testing session_encode() : basic functionality ***\n";
15
16// Get an unset variable
17$unset_var = 10;
18unset($unset_var);
19
20class classA
21{
22    public function __toString() {
23        return "Hello World!";
24    }
25}
26
27$heredoc = <<<EOT
28Hello World!
29EOT;
30
31$fp = fopen(__FILE__, "r");
32
33// Unexpected values to be passed as arguments
34$inputs = array(
35
36       // Integer data
37/*1*/  0,
38       1,
39       12345,
40       -2345,
41
42       // Float data
43/*5*/  10.5,
44       -10.5,
45       12.3456789000e10,
46       12.3456789000E-10,
47       .5,
48
49       // Null data
50/*10*/ NULL,
51       null,
52
53       // Boolean data
54/*12*/ true,
55       false,
56       TRUE,
57       FALSE,
58
59       // Empty strings
60/*16*/ "",
61       '',
62
63       // Invalid string data
64/*18*/ "Nothing",
65       'Nothing',
66       $heredoc,
67
68       // Object data
69/*21*/ new classA(),
70
71       // Undefined data
72/*22*/ @$undefined_var,
73
74       // Unset data
75/*23*/ @$unset_var,
76
77       // Resource variable
78/*24*/ $fp
79);
80
81var_dump(session_start());
82$iterator = 1;
83foreach($inputs as $input) {
84    echo "\n-- Iteration $iterator --\n";
85    $_SESSION["data"] = $input;
86    var_dump(session_encode());
87    $iterator++;
88};
89
90var_dump(session_destroy());
91fclose($fp);
92echo "Done";
93ob_end_flush();
94?>
95--EXPECTF--
96*** Testing session_encode() : basic functionality ***
97bool(true)
98
99-- Iteration 1 --
100string(9) "data|i:0;"
101
102-- Iteration 2 --
103string(9) "data|i:1;"
104
105-- Iteration 3 --
106string(13) "data|i:12345;"
107
108-- Iteration 4 --
109string(13) "data|i:-2345;"
110
111-- Iteration 5 --
112string(12) "data|d:10.5;"
113
114-- Iteration 6 --
115string(13) "data|d:-10.5;"
116
117-- Iteration 7 --
118string(20) "data|d:123456789000;"
119
120-- Iteration 8 --
121string(%d) "data|d:1.2345678899999999145113427164344339914681114578343112953007221221923828125E-9;"
122
123-- Iteration 9 --
124string(11) "data|d:0.5;"
125
126-- Iteration 10 --
127string(7) "data|N;"
128
129-- Iteration 11 --
130string(7) "data|N;"
131
132-- Iteration 12 --
133string(9) "data|b:1;"
134
135-- Iteration 13 --
136string(9) "data|b:0;"
137
138-- Iteration 14 --
139string(9) "data|b:1;"
140
141-- Iteration 15 --
142string(9) "data|b:0;"
143
144-- Iteration 16 --
145string(12) "data|s:0:"";"
146
147-- Iteration 17 --
148string(12) "data|s:0:"";"
149
150-- Iteration 18 --
151string(19) "data|s:7:"Nothing";"
152
153-- Iteration 19 --
154string(19) "data|s:7:"Nothing";"
155
156-- Iteration 20 --
157string(25) "data|s:12:"Hello World!";"
158
159-- Iteration 21 --
160string(22) "data|O:6:"classA":0:{}"
161
162-- Iteration 22 --
163string(7) "data|N;"
164
165-- Iteration 23 --
166string(7) "data|N;"
167
168-- Iteration 24 --
169string(9) "data|i:0;"
170bool(true)
171Done
172