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