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