1--TEST-- 2Test array_product() function : usage variation 3--FILE-- 4<?php 5/* Prototype : mixed array_product(array input) 6 * Description: Returns the product of the array entries 7 * Source code: ext/standard/array.c 8 * Alias to functions: 9 */ 10 11echo "*** Testing array_product() : usage variation ***\n"; 12 13// Initialise function arguments not being substituted (if any) 14 15//get an unset variable 16$unset_var = 10; 17unset ($unset_var); 18 19// define some classes 20class classWithToString 21{ 22 public function __toString() { 23 return "Class A object"; 24 } 25} 26 27class classWithoutToString 28{ 29} 30 31// heredoc string 32$heredoc = <<<EOT 33hello world 34EOT; 35 36// add arrays 37$index_array = array (1, 2, 3); 38$assoc_array = array ('one' => 1, 'two' => 2); 39 40//array of values to iterate over 41$inputs = array( 42 43 // int data 44 'int 0' => 0, 45 'int 1' => 1, 46 'int 12345' => 12345, 47 'int -12345' => -2345, 48 49 // float data 50 'float 10.5' => 10.5, 51 'float -10.5' => -10.5, 52 'float 12.3456789000e10' => 12.3456789000e10, 53 'float -12.3456789000e10' => -12.3456789000e10, 54 'float .5' => .5, 55 56 // null data 57 'uppercase NULL' => NULL, 58 'lowercase null' => null, 59 60 // boolean data 61 'lowercase true' => true, 62 'lowercase false' =>false, 63 'uppercase TRUE' =>TRUE, 64 'uppercase FALSE' =>FALSE, 65 66 // empty data 67 'empty string DQ' => "", 68 'empty string SQ' => '', 69 70 // string data 71 'string DQ' => "string", 72 'string SQ' => 'string', 73 'mixed case string' => "sTrInG", 74 'heredoc' => $heredoc, 75 76 // object data 77 'instance of classWithToString' => new classWithToString(), 78 'instance of classWithoutToString' => new classWithoutToString(), 79 80 // undefined data 81 'undefined var' => @$undefined_var, 82 83 // unset data 84 'unset var' => @$unset_var, 85); 86 87// loop through each element of the array for input 88 89foreach($inputs as $key =>$value) { 90 echo "\n--$key--\n"; 91 var_dump( array_product($value) ); 92}; 93 94?> 95===DONE=== 96--EXPECTF-- 97*** Testing array_product() : usage variation *** 98 99--int 0-- 100 101Warning: array_product() expects parameter 1 to be array, int given in %sarray_product_variation5.php on line %d 102NULL 103 104--int 1-- 105 106Warning: array_product() expects parameter 1 to be array, int given in %sarray_product_variation5.php on line %d 107NULL 108 109--int 12345-- 110 111Warning: array_product() expects parameter 1 to be array, int given in %sarray_product_variation5.php on line %d 112NULL 113 114--int -12345-- 115 116Warning: array_product() expects parameter 1 to be array, int given in %sarray_product_variation5.php on line %d 117NULL 118 119--float 10.5-- 120 121Warning: array_product() expects parameter 1 to be array, float given in %sarray_product_variation5.php on line %d 122NULL 123 124--float -10.5-- 125 126Warning: array_product() expects parameter 1 to be array, float given in %sarray_product_variation5.php on line %d 127NULL 128 129--float 12.3456789000e10-- 130 131Warning: array_product() expects parameter 1 to be array, float given in %sarray_product_variation5.php on line %d 132NULL 133 134--float -12.3456789000e10-- 135 136Warning: array_product() expects parameter 1 to be array, float given in %sarray_product_variation5.php on line %d 137NULL 138 139--float .5-- 140 141Warning: array_product() expects parameter 1 to be array, float given in %sarray_product_variation5.php on line %d 142NULL 143 144--uppercase NULL-- 145 146Warning: array_product() expects parameter 1 to be array, null given in %sarray_product_variation5.php on line %d 147NULL 148 149--lowercase null-- 150 151Warning: array_product() expects parameter 1 to be array, null given in %sarray_product_variation5.php on line %d 152NULL 153 154--lowercase true-- 155 156Warning: array_product() expects parameter 1 to be array, bool given in %sarray_product_variation5.php on line %d 157NULL 158 159--lowercase false-- 160 161Warning: array_product() expects parameter 1 to be array, bool given in %sarray_product_variation5.php on line %d 162NULL 163 164--uppercase TRUE-- 165 166Warning: array_product() expects parameter 1 to be array, bool given in %sarray_product_variation5.php on line %d 167NULL 168 169--uppercase FALSE-- 170 171Warning: array_product() expects parameter 1 to be array, bool given in %sarray_product_variation5.php on line %d 172NULL 173 174--empty string DQ-- 175 176Warning: array_product() expects parameter 1 to be array, string given in %sarray_product_variation5.php on line %d 177NULL 178 179--empty string SQ-- 180 181Warning: array_product() expects parameter 1 to be array, string given in %sarray_product_variation5.php on line %d 182NULL 183 184--string DQ-- 185 186Warning: array_product() expects parameter 1 to be array, string given in %sarray_product_variation5.php on line %d 187NULL 188 189--string SQ-- 190 191Warning: array_product() expects parameter 1 to be array, string given in %sarray_product_variation5.php on line %d 192NULL 193 194--mixed case string-- 195 196Warning: array_product() expects parameter 1 to be array, string given in %sarray_product_variation5.php on line %d 197NULL 198 199--heredoc-- 200 201Warning: array_product() expects parameter 1 to be array, string given in %sarray_product_variation5.php on line %d 202NULL 203 204--instance of classWithToString-- 205 206Warning: array_product() expects parameter 1 to be array, object given in %sarray_product_variation5.php on line %d 207NULL 208 209--instance of classWithoutToString-- 210 211Warning: array_product() expects parameter 1 to be array, object given in %sarray_product_variation5.php on line %d 212NULL 213 214--undefined var-- 215 216Warning: array_product() expects parameter 1 to be array, null given in %sarray_product_variation5.php on line %d 217NULL 218 219--unset var-- 220 221Warning: array_product() expects parameter 1 to be array, null given in %sarray_product_variation5.php on line %d 222NULL 223===DONE=== 224