1--TEST--
2Test session_encode() function : error functionality
3--EXTENSIONS--
4session
5--SKIPIF--
6<?php include('skipif.inc'); ?>
7--FILE--
8<?php
9
10ob_start();
11
12echo "*** Testing session_encode() : error functionality ***\n";
13
14// Unexpected values to be passed as arguments
15$inputs = array(
16
17       // Integer data
18/*1*/  0,
19       1,
20       12345,
21       -2345,
22
23       // Empty strings
24       '',
25
26       // Invalid string data
27       'Nothing',
28);
29
30$iterator = 1;
31foreach($inputs as $input) {
32    echo "\n-- Iteration $iterator --\n";
33    var_dump(session_start());
34    try {
35        $_SESSION[$input] = "Hello World!";
36    } catch (Error $e) {
37        echo $e->getMessage(), "\n";
38    }
39    var_dump(session_encode());
40    var_dump(session_destroy());
41    $iterator++;
42};
43
44echo "Done";
45ob_end_flush();
46?>
47--EXPECTF--
48*** Testing session_encode() : error functionality ***
49
50-- Iteration 1 --
51bool(true)
52
53Warning: session_encode(): Skipping numeric key 0 in %s on line %d
54bool(false)
55bool(true)
56
57-- Iteration 2 --
58bool(true)
59
60Warning: session_encode(): Skipping numeric key 1 in %s on line %d
61bool(false)
62bool(true)
63
64-- Iteration 3 --
65bool(true)
66
67Warning: session_encode(): Skipping numeric key 12345 in %s on line %d
68bool(false)
69bool(true)
70
71-- Iteration 4 --
72bool(true)
73
74Warning: session_encode(): Skipping numeric key -2345 in %s on line %d
75bool(false)
76bool(true)
77
78-- Iteration 5 --
79bool(true)
80string(21) "|s:12:"Hello World!";"
81bool(true)
82
83-- Iteration 6 --
84bool(true)
85string(28) "Nothing|s:12:"Hello World!";"
86bool(true)
87Done
88