1--TEST-- 2Test array_flip() function : usage variations - unexpected values for 'input' argument 3--FILE-- 4<?php 5/* Prototype : array array_flip(array $input) 6 * Description: Return array with key <-> value flipped 7 * Source code: ext/standard/array.c 8*/ 9 10echo "*** Testing array_flip() : usage variations - unexpected values for 'input' ***\n"; 11 12//get an unset variable 13$unset_var = 10; 14unset ($unset_var); 15 16//class definition for object variable 17class MyClass 18{ 19 public function __toString() 20 { 21 return 'object'; 22 } 23} 24 25//resource variable 26$fp = fopen(__FILE__,'r'); 27 28//array of values for 'input' argument 29$values = array( 30 // int data 31 /*1*/ 0, 32 1, 33 12345, 34 -2345, 35 36 // float data 37 /*5*/ 10.5, 38 -10.5, 39 10.5e10, 40 10.6E-10, 41 .5, 42 43 // null data 44 /*10*/ NULL, 45 null, 46 47 // boolean data 48 /*12*/ true, 49 false, 50 TRUE, 51 /*15*/ FALSE, 52 53 // empty data 54 "", 55 '', 56 57 // string data 58 "string", 59 'string', 60 61 // object data 62 /*20*/ new MyClass(), 63 64 // undefined data 65 @$undefined_var, 66 67 // unset data 68 @$unset_var, 69 70 //resource data 71 /*23*/ $fp 72); 73 74// loop through each element of $values for 'input' argument 75for($count = 0; $count < count($values); $count++) { 76 echo "-- Iteration ".($count + 1). " --\n"; 77 var_dump( array_flip($values[$count]) ); 78}; 79 80//closing resource 81fclose($fp); 82 83echo "Done" 84?> 85--EXPECTF-- 86*** Testing array_flip() : usage variations - unexpected values for 'input' *** 87-- Iteration 1 -- 88 89Warning: array_flip() expects parameter 1 to be array, int given in %s on line %d 90NULL 91-- Iteration 2 -- 92 93Warning: array_flip() expects parameter 1 to be array, int given in %s on line %d 94NULL 95-- Iteration 3 -- 96 97Warning: array_flip() expects parameter 1 to be array, int given in %s on line %d 98NULL 99-- Iteration 4 -- 100 101Warning: array_flip() expects parameter 1 to be array, int given in %s on line %d 102NULL 103-- Iteration 5 -- 104 105Warning: array_flip() expects parameter 1 to be array, float given in %s on line %d 106NULL 107-- Iteration 6 -- 108 109Warning: array_flip() expects parameter 1 to be array, float given in %s on line %d 110NULL 111-- Iteration 7 -- 112 113Warning: array_flip() expects parameter 1 to be array, float given in %s on line %d 114NULL 115-- Iteration 8 -- 116 117Warning: array_flip() expects parameter 1 to be array, float given in %s on line %d 118NULL 119-- Iteration 9 -- 120 121Warning: array_flip() expects parameter 1 to be array, float given in %s on line %d 122NULL 123-- Iteration 10 -- 124 125Warning: array_flip() expects parameter 1 to be array, null given in %s on line %d 126NULL 127-- Iteration 11 -- 128 129Warning: array_flip() expects parameter 1 to be array, null given in %s on line %d 130NULL 131-- Iteration 12 -- 132 133Warning: array_flip() expects parameter 1 to be array, bool given in %s on line %d 134NULL 135-- Iteration 13 -- 136 137Warning: array_flip() expects parameter 1 to be array, bool given in %s on line %d 138NULL 139-- Iteration 14 -- 140 141Warning: array_flip() expects parameter 1 to be array, bool given in %s on line %d 142NULL 143-- Iteration 15 -- 144 145Warning: array_flip() expects parameter 1 to be array, bool given in %s on line %d 146NULL 147-- Iteration 16 -- 148 149Warning: array_flip() expects parameter 1 to be array, string given in %s on line %d 150NULL 151-- Iteration 17 -- 152 153Warning: array_flip() expects parameter 1 to be array, string given in %s on line %d 154NULL 155-- Iteration 18 -- 156 157Warning: array_flip() expects parameter 1 to be array, string given in %s on line %d 158NULL 159-- Iteration 19 -- 160 161Warning: array_flip() expects parameter 1 to be array, string given in %s on line %d 162NULL 163-- Iteration 20 -- 164 165Warning: array_flip() expects parameter 1 to be array, object given in %s on line %d 166NULL 167-- Iteration 21 -- 168 169Warning: array_flip() expects parameter 1 to be array, null given in %s on line %d 170NULL 171-- Iteration 22 -- 172 173Warning: array_flip() expects parameter 1 to be array, null given in %s on line %d 174NULL 175-- Iteration 23 -- 176 177Warning: array_flip() expects parameter 1 to be array, resource given in %s on line %d 178NULL 179Done 180