1--TEST-- 2Test pow() function : usage variations - different data types as $exp argument 3--INI-- 4precision = 14 5--FILE-- 6<?php 7/* Prototype : number pow ( number $base , number $exp ) 8 * Description: Exponential expression. 9 * Source code: ext/standard/math.c 10 */ 11 12echo "*** Testing pow() : usage variations ***\n"; 13 14//get an unset variable 15$unset_var = 10; 16unset ($unset_var); 17 18// heredoc string 19$heredoc = <<<EOT 20abc 21xyz 22EOT; 23 24// get a class 25class classA 26{ 27} 28 29// get a resource variable 30$fp = fopen(__FILE__, "r"); 31 32$inputs = array( 33 // int data 34/*1*/ 0, 35 1, 36 12345, 37 -2345, 38 2147483647, 39 40 // float data 41/*6*/ 2.5, 42 -2.5, 43 12.3456789000e10, 44 12.3456789000E-10, 45 .5, 46 47 // null data 48/*11*/ NULL, 49 null, 50 51 // boolean data 52/*13*/ true, 53 false, 54 TRUE, 55 FALSE, 56 57 // empty data 58/*17*/ "", 59 '', 60 array(), 61 62 // string data 63/*20*/ "abcxyz", 64 'abcxyz', 65 $heredoc, 66 67 // object data 68/*23*/ new classA(), 69 70 // undefined data 71/*24*/ @$undefined_var, 72 73 // unset data 74/*25*/ @$unset_var, 75 76 // resource variable 77/*26*/ $fp 78); 79 80// loop through each element of $inputs to check the behaviour of pow() 81$iterator = 1; 82foreach($inputs as $input) { 83 echo "\n-- Iteration $iterator --\n"; 84 var_dump(pow(20.3, $input)); 85 $iterator++; 86}; 87fclose($fp); 88?> 89===Done=== 90--EXPECTF-- 91*** Testing pow() : usage variations *** 92 93-- Iteration 1 -- 94float(1) 95 96-- Iteration 2 -- 97float(20.3) 98 99-- Iteration 3 -- 100float(INF) 101 102-- Iteration 4 -- 103float(0) 104 105-- Iteration 5 -- 106float(INF) 107 108-- Iteration 6 -- 109float(1856.6929774279) 110 111-- Iteration 7 -- 112float(0.00053859200856424) 113 114-- Iteration 8 -- 115float(INF) 116 117-- Iteration 9 -- 118float(1.0000000037168) 119 120-- Iteration 10 -- 121float(4.5055521304275) 122 123-- Iteration 11 -- 124float(1) 125 126-- Iteration 12 -- 127float(1) 128 129-- Iteration 13 -- 130float(20.3) 131 132-- Iteration 14 -- 133float(1) 134 135-- Iteration 15 -- 136float(20.3) 137 138-- Iteration 16 -- 139float(1) 140 141-- Iteration 17 -- 142 143Warning: A non-numeric value encountered in %s on line %d 144float(1) 145 146-- Iteration 18 -- 147 148Warning: A non-numeric value encountered in %s on line %d 149float(1) 150 151-- Iteration 19 -- 152int(1) 153 154-- Iteration 20 -- 155 156Warning: A non-numeric value encountered in %s on line %d 157float(1) 158 159-- Iteration 21 -- 160 161Warning: A non-numeric value encountered in %s on line %d 162float(1) 163 164-- Iteration 22 -- 165 166Warning: A non-numeric value encountered in %s on line %d 167float(1) 168 169-- Iteration 23 -- 170 171Notice: Object of class classA could not be converted to int in %s on line %d 172float(20.3) 173 174-- Iteration 24 -- 175float(1) 176 177-- Iteration 25 -- 178float(1) 179 180-- Iteration 26 -- 181%s 182===Done=== 183