1--TEST-- 2Test is_a() function : usage variations - wrong type for arg 2 3--INI-- 4error_reporting=E_ALL | E_STRICT | E_DEPRECATED 5--FILE-- 6<?php 7/* Prototype : proto bool is_a(object object, string class_name) 8 * Description: Returns true if the object is of this class or has this class as one of its parents 9 * Source code: Zend/zend_builtin_functions.c 10 * Alias to functions: 11 */ 12 13class C { 14 function __toString() { 15 return "C Instance"; 16 } 17} 18 19echo "*** Testing is_a() : usage variations ***\n"; 20 21// Initialise function arguments not being substituted (if any) 22$object = new stdclass(); 23 24//get an unset variable 25$unset_var = 10; 26unset ($unset_var); 27 28//array of values to iterate over 29$values = array( 30 31 // int data 32 0, 33 1, 34 12345, 35 -2345, 36 37 // float data 38 10.5, 39 -10.5, 40 10.1234567e10, 41 10.7654321E-10, 42 .5, 43 44 // array data 45 array(), 46 array(0), 47 array(1), 48 array(1, 2), 49 array('color' => 'red', 'item' => 'pen'), 50 51 // null data 52 NULL, 53 null, 54 55 // boolean data 56 true, 57 false, 58 TRUE, 59 FALSE, 60 61 // empty data 62 "", 63 '', 64 65 // object data 66 new C, 67 68 // undefined data 69 $undefined_var, 70 71 // unset data 72 $unset_var, 73); 74 75// loop through each element of the array for class_name 76 77foreach($values as $value) { 78 echo "\nArg value $value \n"; 79 var_dump( is_a($object, $value) ); 80}; 81 82echo "Done"; 83?> 84--EXPECTF-- 85*** Testing is_a() : usage variations *** 86 87Notice: Undefined variable: undefined_var in %s on line 64 88 89Notice: Undefined variable: unset_var in %s on line 67 90 91Arg value 0 92bool(false) 93 94Arg value 1 95bool(false) 96 97Arg value 12345 98bool(false) 99 100Arg value -2345 101bool(false) 102 103Arg value 10.5 104bool(false) 105 106Arg value -10.5 107bool(false) 108 109Arg value 101234567000 110bool(false) 111 112Arg value 1.07654321E-9 113bool(false) 114 115Arg value 0.5 116bool(false) 117 118Arg value Array 119 120Warning: is_a() expects parameter 2 to be string, array given in %s on line %d 121NULL 122 123Arg value Array 124 125Warning: is_a() expects parameter 2 to be string, array given in %s on line %d 126NULL 127 128Arg value Array 129 130Warning: is_a() expects parameter 2 to be string, array given in %s on line %d 131NULL 132 133Arg value Array 134 135Warning: is_a() expects parameter 2 to be string, array given in %s on line %d 136NULL 137 138Arg value Array 139 140Warning: is_a() expects parameter 2 to be string, array given in %s on line %d 141NULL 142 143Arg value 144bool(false) 145 146Arg value 147bool(false) 148 149Arg value 1 150bool(false) 151 152Arg value 153bool(false) 154 155Arg value 1 156bool(false) 157 158Arg value 159bool(false) 160 161Arg value 162bool(false) 163 164Arg value 165bool(false) 166 167Arg value C Instance 168bool(false) 169 170Arg value 171bool(false) 172 173Arg value 174bool(false) 175Done 176