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