1--TEST-- 2Test session_name() function : error functionality 3--INI-- 4session.save_path= 5session.name=PHPSESSID 6--SKIPIF-- 7<?php include('skipif.inc'); ?> 8--FILE-- 9<?php 10 11ob_start(); 12 13/* 14 * Prototype : string session_name([string $name]) 15 * Description : Get and/or set the current session name 16 * Source code : ext/session/session.c 17 */ 18 19echo "*** Testing session_name() : error functionality ***\n"; 20 21// Get an unset variable 22$unset_var = 10; 23unset($unset_var); 24 25class classA 26{ 27 public function __toString() { 28 return "Hello World!"; 29 } 30} 31 32$heredoc = <<<EOT 33Hello World! 34EOT; 35 36$fp = fopen(__FILE__, "r"); 37 38// Unexpected values to be passed as arguments 39$inputs = array( 40 41 // Integer data 42/*1*/ 0, 43 1, 44 12345, 45 -2345, 46 47 // Float data 48/*5*/ 10.5, 49 -10.5, 50 12.3456789000e10, 51 12.3456789000E-10, 52 .5, 53 54 // Null data 55/*10*/ NULL, 56 null, 57 58 // Boolean data 59/*12*/ true, 60 false, 61 TRUE, 62 FALSE, 63 64 // Empty strings 65/*16*/ "", 66 '', 67 68 // Invalid string data 69/*18*/ "Nothing", 70 'Nothing', 71 $heredoc, 72 73 // Object data 74/*21*/ new classA(), 75 76 // Undefined data 77/*22*/ @$undefined_var, 78 79 // Unset data 80/*23*/ @$unset_var, 81 82 // Resource variable 83/*24*/ $fp 84); 85 86$iterator = 1; 87foreach($inputs as $input) { 88 echo "\n-- Iteration $iterator --\n"; 89 var_dump($input, session_name($input)); 90 $iterator++; 91}; 92 93fclose($fp); 94echo "Done"; 95ob_end_flush(); 96?> 97--EXPECTF-- 98*** Testing session_name() : error functionality *** 99 100-- Iteration 1 -- 101 102Warning: session_name(): session.name cannot be a numeric or empty '0' in %s on line %d 103int(0) 104string(9) "PHPSESSID" 105 106-- Iteration 2 -- 107 108Warning: session_name(): session.name cannot be a numeric or empty '1' in %s on line %d 109int(1) 110string(9) "PHPSESSID" 111 112-- Iteration 3 -- 113 114Warning: session_name(): session.name cannot be a numeric or empty '12345' in %s on line %d 115int(12345) 116string(9) "PHPSESSID" 117 118-- Iteration 4 -- 119 120Warning: session_name(): session.name cannot be a numeric or empty '-2345' in %s on line %d 121int(-2345) 122string(9) "PHPSESSID" 123 124-- Iteration 5 -- 125 126Warning: session_name(): session.name cannot be a numeric or empty '10.5' in %s on line %d 127float(10.5) 128string(9) "PHPSESSID" 129 130-- Iteration 6 -- 131 132Warning: session_name(): session.name cannot be a numeric or empty '-10.5' in %s on line %d 133float(-10.5) 134string(9) "PHPSESSID" 135 136-- Iteration 7 -- 137 138Warning: session_name(): session.name cannot be a numeric or empty '123456789000' in %s on line %d 139float(123456789000) 140string(9) "PHPSESSID" 141 142-- Iteration 8 -- 143 144Warning: session_name(): session.name cannot be a numeric or empty '1.23456789E-9' in %s on line %d 145float(1.23456789E-9) 146string(9) "PHPSESSID" 147 148-- Iteration 9 -- 149 150Warning: session_name(): session.name cannot be a numeric or empty '0.5' in %s on line %d 151float(0.5) 152string(9) "PHPSESSID" 153 154-- Iteration 10 -- 155 156Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d 157NULL 158string(9) "PHPSESSID" 159 160-- Iteration 11 -- 161 162Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d 163NULL 164string(9) "PHPSESSID" 165 166-- Iteration 12 -- 167 168Warning: session_name(): session.name cannot be a numeric or empty '1' in %s on line %d 169bool(true) 170string(9) "PHPSESSID" 171 172-- Iteration 13 -- 173 174Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d 175bool(false) 176string(9) "PHPSESSID" 177 178-- Iteration 14 -- 179 180Warning: session_name(): session.name cannot be a numeric or empty '1' in %s on line %d 181bool(true) 182string(9) "PHPSESSID" 183 184-- Iteration 15 -- 185 186Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d 187bool(false) 188string(9) "PHPSESSID" 189 190-- Iteration 16 -- 191 192Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d 193string(0) "" 194string(9) "PHPSESSID" 195 196-- Iteration 17 -- 197 198Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d 199string(0) "" 200string(9) "PHPSESSID" 201 202-- Iteration 18 -- 203string(7) "Nothing" 204string(9) "PHPSESSID" 205 206-- Iteration 19 -- 207string(7) "Nothing" 208string(7) "Nothing" 209 210-- Iteration 20 -- 211string(12) "Hello World!" 212string(7) "Nothing" 213 214-- Iteration 21 -- 215object(classA)#1 (0) { 216} 217string(12) "Hello World!" 218 219-- Iteration 22 -- 220 221Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d 222NULL 223string(12) "Hello World!" 224 225-- Iteration 23 -- 226 227Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d 228NULL 229string(12) "Hello World!" 230 231-- Iteration 24 -- 232 233Warning: session_name() expects parameter 1 to be string, resource given in %s on line %d 234resource(%d) of type (stream) 235NULL 236Done 237