1--TEST-- 2Test xml_set_object() function : usage variations 3--SKIPIF-- 4<?php 5if (!extension_loaded("xml")) { 6 print "skip - XML extension not loaded"; 7} 8?> 9--FILE-- 10<?php 11/* Prototype : proto int xml_set_object(resource parser, object &obj) 12 * Description: Set up object which should be used for callbacks 13 * Source code: ext/xml/xml.c 14 * Alias to functions: 15 */ 16 17echo "*** Testing xml_set_object() : usage variations ***\n"; 18error_reporting(E_ALL & ~E_NOTICE); 19// Initialise function arguments not being substituted (if any) 20 21$parser = xml_parser_create(); 22$fp = fopen(__FILE__, "r"); 23 24 25//get an unset variable 26$unset_var = 10; 27unset ($unset_var); 28 29//array of values to iterate over 30$values = array( 31 32 // int data 33 0, 34 1, 35 12345, 36 -2345, 37 38 // float data 39 10.5, 40 -10.5, 41 10.1234567e10, 42 10.7654321E-10, 43 .5, 44 45 // array data 46 array(), 47 array(0), 48 array(1), 49 array(1, 2), 50 array('color' => 'red', 'item' => 'pen'), 51 52 // null data 53 NULL, 54 null, 55 56 // boolean data 57 true, 58 false, 59 TRUE, 60 FALSE, 61 62 // empty data 63 "", 64 '', 65 66 // string data 67 "string", 68 'string', 69 70 // resource data 71 $fp, 72 73 // undefined data 74 $undefined_var, 75 76 // unset data 77 $unset_var, 78); 79 80// loop through each element of the array for obj 81 82foreach($values as $value) { 83 echo @"\nArg value $value \n"; 84 var_dump( xml_set_object($parser, $value) ); 85}; 86 87xml_parser_free($parser); 88fclose($fp); 89 90echo "Done"; 91?> 92--EXPECTF-- 93*** Testing xml_set_object() : usage variations *** 94 95Arg value 0 96 97Warning: xml_set_object() expects parameter 2 to be object, int given in %s on line %d 98NULL 99 100Arg value 1 101 102Warning: xml_set_object() expects parameter 2 to be object, int given in %s on line %d 103NULL 104 105Arg value 12345 106 107Warning: xml_set_object() expects parameter 2 to be object, int given in %s on line %d 108NULL 109 110Arg value -2345 111 112Warning: xml_set_object() expects parameter 2 to be object, int given in %s on line %d 113NULL 114 115Arg value 10.5 116 117Warning: xml_set_object() expects parameter 2 to be object, float given in %s on line %d 118NULL 119 120Arg value -10.5 121 122Warning: xml_set_object() expects parameter 2 to be object, float given in %s on line %d 123NULL 124 125Arg value 101234567000 126 127Warning: xml_set_object() expects parameter 2 to be object, float given in %s on line %d 128NULL 129 130Arg value 1.07654321E-9 131 132Warning: xml_set_object() expects parameter 2 to be object, float given in %s on line %d 133NULL 134 135Arg value 0.5 136 137Warning: xml_set_object() expects parameter 2 to be object, float given in %s on line %d 138NULL 139 140Arg value Array 141 142Warning: xml_set_object() expects parameter 2 to be object, array given in %s on line %d 143NULL 144 145Arg value Array 146 147Warning: xml_set_object() expects parameter 2 to be object, array given in %s on line %d 148NULL 149 150Arg value Array 151 152Warning: xml_set_object() expects parameter 2 to be object, array given in %s on line %d 153NULL 154 155Arg value Array 156 157Warning: xml_set_object() expects parameter 2 to be object, array given in %s on line %d 158NULL 159 160Arg value Array 161 162Warning: xml_set_object() expects parameter 2 to be object, array given in %s on line %d 163NULL 164 165Arg value 166 167Warning: xml_set_object() expects parameter 2 to be object, null given in %s on line %d 168NULL 169 170Arg value 171 172Warning: xml_set_object() expects parameter 2 to be object, null given in %s on line %d 173NULL 174 175Arg value 1 176 177Warning: xml_set_object() expects parameter 2 to be object, bool given in %s on line %d 178NULL 179 180Arg value 181 182Warning: xml_set_object() expects parameter 2 to be object, bool given in %s on line %d 183NULL 184 185Arg value 1 186 187Warning: xml_set_object() expects parameter 2 to be object, bool given in %s on line %d 188NULL 189 190Arg value 191 192Warning: xml_set_object() expects parameter 2 to be object, bool given in %s on line %d 193NULL 194 195Arg value 196 197Warning: xml_set_object() expects parameter 2 to be object, string given in %s on line %d 198NULL 199 200Arg value 201 202Warning: xml_set_object() expects parameter 2 to be object, string given in %s on line %d 203NULL 204 205Arg value string 206 207Warning: xml_set_object() expects parameter 2 to be object, string given in %s on line %d 208NULL 209 210Arg value string 211 212Warning: xml_set_object() expects parameter 2 to be object, string given in %s on line %d 213NULL 214 215Arg value Resource id %s 216 217Warning: xml_set_object() expects parameter 2 to be object, resource given in %s on line %d 218NULL 219 220Arg value 221 222Warning: xml_set_object() expects parameter 2 to be object, null given in %s on line %d 223NULL 224 225Arg value 226 227Warning: xml_set_object() expects parameter 2 to be object, null given in %s on line %d 228NULL 229Done 230