Return to octdec_variation1.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / math |
1.1 misho 1: --TEST-- 2: Test octdec() function : usage variations - different data types as $octal_string arg 3: --INI-- 4: precision=14 5: --FILE-- 6: <?php 7: /* Prototype : number octdec ( string $octal_string ) 8: * Description: Returns the decimal equivalent of the octal number represented by the octal_string argument. 9: * Source code: ext/standard/math.c 10: */ 11: 12: echo "*** Testing octdec() : usage variations ***\n"; 13: //get an unset variable 14: $unset_var = 10; 15: unset ($unset_var); 16: 17: // heredoc string 18: $heredoc = <<<EOT 19: abc 20: xyz 21: EOT; 22: 23: // get a resource variable 24: $fp = fopen(__FILE__, "r"); 25: 26: $inputs = array( 27: // int data 28: /*1*/ 0, 29: 1, 30: 12345, 31: -2345, 32: 4294967295, // largest decimal 33: 4294967296, 34: 35: // float data 36: /*7*/ 10.5, 37: -10.5, 38: 12.3456789000e10, 39: 12.3456789000E-10, 40: .5, 41: 42: // null data 43: /*12*/ NULL, 44: null, 45: 46: // boolean data 47: /*14*/ true, 48: false, 49: TRUE, 50: FALSE, 51: 52: // empty data 53: /*18*/ "", 54: '', 55: array(), 56: 57: // string data 58: /*21*/ "abcxyz", 59: 'abcxyz', 60: $heredoc, 61: 62: // undefined data 63: /*24*/ @$undefined_var, 64: 65: // unset data 66: /*25*/ @$unset_var, 67: 68: // resource variable 69: /*26*/ $fp 70: ); 71: 72: // loop through each element of $inputs to check the behaviour of octdec() 73: $iterator = 1; 74: foreach($inputs as $input) { 75: echo "\n-- Iteration $iterator --\n"; 76: var_dump(octdec($input)); 77: $iterator++; 78: }; 79: fclose($fp); 80: ?> 81: ---Done--- 82: --EXPECTF-- 83: *** Testing octdec() : usage variations *** 84: 85: -- Iteration 1 -- 86: int(0) 87: 88: -- Iteration 2 -- 89: int(1) 90: 91: -- Iteration 3 -- 92: int(5349) 93: 94: -- Iteration 4 -- 95: int(1253) 96: 97: -- Iteration 5 -- 98: int(1134037) 99: 100: -- Iteration 6 -- 101: int(1134038) 102: 103: -- Iteration 7 -- 104: int(69) 105: 106: -- Iteration 8 -- 107: int(69) 108: 109: -- Iteration 9 -- 110: int(175304192) 111: 112: -- Iteration 10 -- 113: int(342391) 114: 115: -- Iteration 11 -- 116: int(5) 117: 118: -- Iteration 12 -- 119: int(0) 120: 121: -- Iteration 13 -- 122: int(0) 123: 124: -- Iteration 14 -- 125: int(1) 126: 127: -- Iteration 15 -- 128: int(0) 129: 130: -- Iteration 16 -- 131: int(1) 132: 133: -- Iteration 17 -- 134: int(0) 135: 136: -- Iteration 18 -- 137: int(0) 138: 139: -- Iteration 19 -- 140: int(0) 141: 142: -- Iteration 20 -- 143: 144: Notice: Array to string conversion in %s on line %d 145: int(0) 146: 147: -- Iteration 21 -- 148: int(0) 149: 150: -- Iteration 22 -- 151: int(0) 152: 153: -- Iteration 23 -- 154: int(0) 155: 156: -- Iteration 24 -- 157: int(0) 158: 159: -- Iteration 25 -- 160: int(0) 161: 162: -- Iteration 26 -- 163: int(%d) 164: ---Done---