1--TEST-- 2Test split() function : usage variations - unexpected type for arg 1 3--FILE-- 4<?php 5/* Prototype : proto array split(string pattern, string string [, int limit]) 6 * Description: Split string into array by regular expression 7 * Source code: ext/standard/reg.c 8 * Alias to functions: 9 */ 10 11function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) { 12 echo "Error: $err_no - $err_msg, $filename($linenum)\n"; 13} 14set_error_handler('test_error_handler'); 15 16echo "*** Testing split() : usage variations ***\n"; 17 18// Initialise function arguments not being substituted (if any) 19$string = '1 a 1 Array 1 c '; 20$limit = 5; 21 22//get an unset variable 23$unset_var = 10; 24unset ($unset_var); 25 26//array of values to iterate over 27$values = array( 28 29 // int data 30 0, 31 1, 32 12345, 33 -2345, 34 35 // float data 36 10.5, 37 -10.5, 38 10.1234567e10, 39 10.7654321E-10, 40 .5, 41 42 // array data 43 array(), 44 array(0), 45 array(1), 46 array(1, 2), 47 array('color' => 'red', 'item' => 'pen'), 48 49 // null data 50 NULL, 51 null, 52 53 // boolean data 54 true, 55 false, 56 TRUE, 57 FALSE, 58 59 // empty data 60 "", 61 '', 62 63 // object data 64 new stdclass(), 65 66 // undefined data 67 $undefined_var, 68 69 // unset data 70 $unset_var, 71); 72 73// loop through each element of the array for pattern 74 75foreach($values as $value) { 76 echo "\nArg value $value \n"; 77 var_dump( split($value, $string, $limit) ); 78}; 79 80echo "Done"; 81?> 82--EXPECTF-- 83*** Testing split() : usage variations *** 84Error: 8 - Undefined variable: undefined_var, %s(64) 85Error: 8 - Undefined variable: unset_var, %s(67) 86 87Arg value 0 88Error: 8192 - Function split() is deprecated, %s(74) 89array(1) { 90 [0]=> 91 string(16) "1 a 1 Array 1 c " 92} 93 94Arg value 1 95Error: 8192 - Function split() is deprecated, %s(74) 96array(4) { 97 [0]=> 98 string(0) "" 99 [1]=> 100 string(3) " a " 101 [2]=> 102 string(7) " Array " 103 [3]=> 104 string(3) " c " 105} 106 107Arg value 12345 108Error: 8192 - Function split() is deprecated, %s(74) 109array(1) { 110 [0]=> 111 string(16) "1 a 1 Array 1 c " 112} 113 114Arg value -2345 115Error: 8192 - Function split() is deprecated, %s(74) 116array(1) { 117 [0]=> 118 string(16) "1 a 1 Array 1 c " 119} 120 121Arg value 10.5 122Error: 8192 - Function split() is deprecated, %s(74) 123array(1) { 124 [0]=> 125 string(16) "1 a 1 Array 1 c " 126} 127 128Arg value -10.5 129Error: 8192 - Function split() is deprecated, %s(74) 130array(1) { 131 [0]=> 132 string(16) "1 a 1 Array 1 c " 133} 134 135Arg value 101234567000 136Error: 8192 - Function split() is deprecated, %s(74) 137array(1) { 138 [0]=> 139 string(16) "1 a 1 Array 1 c " 140} 141 142Arg value 1.07654321E-9 143Error: 8192 - Function split() is deprecated, %s(74) 144array(1) { 145 [0]=> 146 string(16) "1 a 1 Array 1 c " 147} 148 149Arg value 0.5 150Error: 8192 - Function split() is deprecated, %s(74) 151array(1) { 152 [0]=> 153 string(16) "1 a 1 Array 1 c " 154} 155Error: 8 - Array to string conversion, %ssplit_variation_001.php(%d) 156 157Arg value Array 158Error: 8192 - Function split() is deprecated, %s(74) 159Error: 2 - split() expects parameter 1 to be string, array given, %s(74) 160NULL 161Error: 8 - Array to string conversion, %ssplit_variation_001.php(%d) 162 163Arg value Array 164Error: 8192 - Function split() is deprecated, %s(74) 165Error: 2 - split() expects parameter 1 to be string, array given, %s(74) 166NULL 167Error: 8 - Array to string conversion, %ssplit_variation_001.php(%d) 168 169Arg value Array 170Error: 8192 - Function split() is deprecated, %s(74) 171Error: 2 - split() expects parameter 1 to be string, array given, %s(74) 172NULL 173Error: 8 - Array to string conversion, %ssplit_variation_001.php(%d) 174 175Arg value Array 176Error: 8192 - Function split() is deprecated, %s(74) 177Error: 2 - split() expects parameter 1 to be string, array given, %s(74) 178NULL 179Error: 8 - Array to string conversion, %ssplit_variation_001.php(%d) 180 181Arg value Array 182Error: 8192 - Function split() is deprecated, %s(74) 183Error: 2 - split() expects parameter 1 to be string, array given, %s(74) 184NULL 185 186Arg value 187Error: 8192 - Function split() is deprecated, %s(74) 188Error: 2 - split(): REG_EMPTY, %s(74) 189bool(false) 190 191Arg value 192Error: 8192 - Function split() is deprecated, %s(74) 193Error: 2 - split(): REG_EMPTY, %s(74) 194bool(false) 195 196Arg value 1 197Error: 8192 - Function split() is deprecated, %s(74) 198array(4) { 199 [0]=> 200 string(0) "" 201 [1]=> 202 string(3) " a " 203 [2]=> 204 string(7) " Array " 205 [3]=> 206 string(3) " c " 207} 208 209Arg value 210Error: 8192 - Function split() is deprecated, %s(74) 211Error: 2 - split(): REG_EMPTY, %s(74) 212bool(false) 213 214Arg value 1 215Error: 8192 - Function split() is deprecated, %s(74) 216array(4) { 217 [0]=> 218 string(0) "" 219 [1]=> 220 string(3) " a " 221 [2]=> 222 string(7) " Array " 223 [3]=> 224 string(3) " c " 225} 226 227Arg value 228Error: 8192 - Function split() is deprecated, %s(74) 229Error: 2 - split(): REG_EMPTY, %s(74) 230bool(false) 231 232Arg value 233Error: 8192 - Function split() is deprecated, %s(74) 234Error: 2 - split(): REG_EMPTY, %s(74) 235bool(false) 236 237Arg value 238Error: 8192 - Function split() is deprecated, %s(74) 239Error: 2 - split(): REG_EMPTY, %s(74) 240bool(false) 241Error: 4096 - Object of class stdClass could not be converted to string, %s(73) 242 243Arg value 244Error: 8192 - Function split() is deprecated, %s(74) 245Error: 2 - split() expects parameter 1 to be string, object given, %s(74) 246NULL 247 248Arg value 249Error: 8192 - Function split() is deprecated, %s(74) 250Error: 2 - split(): REG_EMPTY, %s(74) 251bool(false) 252 253Arg value 254Error: 8192 - Function split() is deprecated, %s(74) 255Error: 2 - split(): REG_EMPTY, %s(74) 256bool(false) 257Done 258