1--TEST-- 2Test rawurldecode() function : usage variations - unexpected type for arg 1. 3--FILE-- 4<?php 5/* Prototype : proto string rawurldecode(string str) 6 * Description: Decodes URL-encodes string 7 * Source code: ext/standard/url.c 8 * Alias to functions: 9 */ 10 11// NB: basic functionality tested in tests/strings/001.phpt 12 13function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) { 14 echo "Error: $err_no - $err_msg, $filename($linenum)\n"; 15} 16set_error_handler('test_error_handler'); 17 18echo "*** Testing rawurldecode() : usage variations ***\n"; 19 20// Initialise function arguments not being substituted (if any) 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 str 74 75foreach($values as $value) { 76 echo "\nArg value $value \n"; 77 var_dump( rawurldecode($value) ); 78}; 79 80echo "Done"; 81?> 82--EXPECTF-- 83*** Testing rawurldecode() : usage variations *** 84Error: 8 - Undefined variable: undefined_var, %s(64) 85Error: 8 - Undefined variable: unset_var, %s(67) 86 87Arg value 0 88string(1) "0" 89 90Arg value 1 91string(1) "1" 92 93Arg value 12345 94string(5) "12345" 95 96Arg value -2345 97string(5) "-2345" 98 99Arg value 10.5 100string(4) "10.5" 101 102Arg value -10.5 103string(5) "-10.5" 104 105Arg value 101234567000 106string(12) "101234567000" 107 108Arg value 1.07654321E-9 109string(13) "1.07654321E-9" 110 111Arg value 0.5 112string(3) "0.5" 113 114Arg value Array 115Error: 2 - rawurldecode() expects parameter 1 to be string, array given, %s(74) 116NULL 117 118Arg value Array 119Error: 2 - rawurldecode() expects parameter 1 to be string, array given, %s(74) 120NULL 121 122Arg value Array 123Error: 2 - rawurldecode() expects parameter 1 to be string, array given, %s(74) 124NULL 125 126Arg value Array 127Error: 2 - rawurldecode() expects parameter 1 to be string, array given, %s(74) 128NULL 129 130Arg value Array 131Error: 2 - rawurldecode() expects parameter 1 to be string, array given, %s(74) 132NULL 133 134Arg value 135string(0) "" 136 137Arg value 138string(0) "" 139 140Arg value 1 141string(1) "1" 142 143Arg value 144string(0) "" 145 146Arg value 1 147string(1) "1" 148 149Arg value 150string(0) "" 151 152Arg value 153string(0) "" 154 155Arg value 156string(0) "" 157Error: 4096 - Object of class stdClass could not be converted to string, %s(73) 158 159Arg value 160Error: 2 - rawurldecode() expects parameter 1 to be string, object given, %s(74) 161NULL 162 163Arg value 164string(0) "" 165 166Arg value 167string(0) "" 168Done