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