Annotation of embedaddon/php/tests/func/003.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: General function test
! 3: --FILE--
! 4: <?php
! 5:
! 6: function a()
! 7: {
! 8: echo "hey\n";
! 9: }
! 10:
! 11: function b($i)
! 12: {
! 13: echo "$i\n";
! 14: }
! 15:
! 16:
! 17: function c($i,$j)
! 18: {
! 19: echo "Counting from $i to $j\n";
! 20: for ($k=$i; $k<=$j; $k++) {
! 21: echo "$k\n";
! 22: }
! 23: }
! 24:
! 25:
! 26:
! 27: a();
! 28: b("blah");
! 29: a();
! 30: b("blah","blah");
! 31: c(7,14);
! 32:
! 33: a();
! 34:
! 35:
! 36: function factorial($n)
! 37: {
! 38: if ($n==0 || $n==1) {
! 39: return 1;
! 40: } else {
! 41: return factorial($n-1)*$n;
! 42: }
! 43: }
! 44:
! 45:
! 46: function factorial2($start, $n)
! 47: {
! 48: if ($n<=$start) {
! 49: return $start;
! 50: } else {
! 51: return factorial2($start,$n-1)*$n;
! 52: }
! 53: }
! 54:
! 55:
! 56: for ($k=0; $k<10; $k++) {
! 57: for ($i=0; $i<=10; $i++) {
! 58: $n=factorial($i);
! 59: echo "factorial($i) = $n\n";
! 60: }
! 61: }
! 62:
! 63:
! 64: echo "and now, from a function...\n";
! 65:
! 66: function call_fact()
! 67: {
! 68: echo "(it should break at 5...)\n";
! 69: for ($i=0; $i<=10; $i++) {
! 70: if ($i == 5) break;
! 71: $n=factorial($i);
! 72: echo "factorial($i) = $n\n";
! 73: }
! 74: }
! 75:
! 76: function return4() { return 4; }
! 77: function return7() { return 7; }
! 78:
! 79: for ($k=0; $k<10; $k++) {
! 80: call_fact();
! 81: }
! 82:
! 83: echo "------\n";
! 84: $result = factorial(factorial(3));
! 85: echo "$result\n";
! 86:
! 87: $result=factorial2(return4(),return7());
! 88: echo "$result\n";
! 89:
! 90: function andi($i, $j)
! 91: {
! 92: for ($k=$i ; $k<=$j ; $k++) {
! 93: if ($k >5) continue;
! 94: echo "$k\n";
! 95: }
! 96: }
! 97:
! 98: andi (3,10);
! 99: --EXPECT--
! 100: hey
! 101: blah
! 102: hey
! 103: blah
! 104: Counting from 7 to 14
! 105: 7
! 106: 8
! 107: 9
! 108: 10
! 109: 11
! 110: 12
! 111: 13
! 112: 14
! 113: hey
! 114: factorial(0) = 1
! 115: factorial(1) = 1
! 116: factorial(2) = 2
! 117: factorial(3) = 6
! 118: factorial(4) = 24
! 119: factorial(5) = 120
! 120: factorial(6) = 720
! 121: factorial(7) = 5040
! 122: factorial(8) = 40320
! 123: factorial(9) = 362880
! 124: factorial(10) = 3628800
! 125: factorial(0) = 1
! 126: factorial(1) = 1
! 127: factorial(2) = 2
! 128: factorial(3) = 6
! 129: factorial(4) = 24
! 130: factorial(5) = 120
! 131: factorial(6) = 720
! 132: factorial(7) = 5040
! 133: factorial(8) = 40320
! 134: factorial(9) = 362880
! 135: factorial(10) = 3628800
! 136: factorial(0) = 1
! 137: factorial(1) = 1
! 138: factorial(2) = 2
! 139: factorial(3) = 6
! 140: factorial(4) = 24
! 141: factorial(5) = 120
! 142: factorial(6) = 720
! 143: factorial(7) = 5040
! 144: factorial(8) = 40320
! 145: factorial(9) = 362880
! 146: factorial(10) = 3628800
! 147: factorial(0) = 1
! 148: factorial(1) = 1
! 149: factorial(2) = 2
! 150: factorial(3) = 6
! 151: factorial(4) = 24
! 152: factorial(5) = 120
! 153: factorial(6) = 720
! 154: factorial(7) = 5040
! 155: factorial(8) = 40320
! 156: factorial(9) = 362880
! 157: factorial(10) = 3628800
! 158: factorial(0) = 1
! 159: factorial(1) = 1
! 160: factorial(2) = 2
! 161: factorial(3) = 6
! 162: factorial(4) = 24
! 163: factorial(5) = 120
! 164: factorial(6) = 720
! 165: factorial(7) = 5040
! 166: factorial(8) = 40320
! 167: factorial(9) = 362880
! 168: factorial(10) = 3628800
! 169: factorial(0) = 1
! 170: factorial(1) = 1
! 171: factorial(2) = 2
! 172: factorial(3) = 6
! 173: factorial(4) = 24
! 174: factorial(5) = 120
! 175: factorial(6) = 720
! 176: factorial(7) = 5040
! 177: factorial(8) = 40320
! 178: factorial(9) = 362880
! 179: factorial(10) = 3628800
! 180: factorial(0) = 1
! 181: factorial(1) = 1
! 182: factorial(2) = 2
! 183: factorial(3) = 6
! 184: factorial(4) = 24
! 185: factorial(5) = 120
! 186: factorial(6) = 720
! 187: factorial(7) = 5040
! 188: factorial(8) = 40320
! 189: factorial(9) = 362880
! 190: factorial(10) = 3628800
! 191: factorial(0) = 1
! 192: factorial(1) = 1
! 193: factorial(2) = 2
! 194: factorial(3) = 6
! 195: factorial(4) = 24
! 196: factorial(5) = 120
! 197: factorial(6) = 720
! 198: factorial(7) = 5040
! 199: factorial(8) = 40320
! 200: factorial(9) = 362880
! 201: factorial(10) = 3628800
! 202: factorial(0) = 1
! 203: factorial(1) = 1
! 204: factorial(2) = 2
! 205: factorial(3) = 6
! 206: factorial(4) = 24
! 207: factorial(5) = 120
! 208: factorial(6) = 720
! 209: factorial(7) = 5040
! 210: factorial(8) = 40320
! 211: factorial(9) = 362880
! 212: factorial(10) = 3628800
! 213: factorial(0) = 1
! 214: factorial(1) = 1
! 215: factorial(2) = 2
! 216: factorial(3) = 6
! 217: factorial(4) = 24
! 218: factorial(5) = 120
! 219: factorial(6) = 720
! 220: factorial(7) = 5040
! 221: factorial(8) = 40320
! 222: factorial(9) = 362880
! 223: factorial(10) = 3628800
! 224: and now, from a function...
! 225: (it should break at 5...)
! 226: factorial(0) = 1
! 227: factorial(1) = 1
! 228: factorial(2) = 2
! 229: factorial(3) = 6
! 230: factorial(4) = 24
! 231: (it should break at 5...)
! 232: factorial(0) = 1
! 233: factorial(1) = 1
! 234: factorial(2) = 2
! 235: factorial(3) = 6
! 236: factorial(4) = 24
! 237: (it should break at 5...)
! 238: factorial(0) = 1
! 239: factorial(1) = 1
! 240: factorial(2) = 2
! 241: factorial(3) = 6
! 242: factorial(4) = 24
! 243: (it should break at 5...)
! 244: factorial(0) = 1
! 245: factorial(1) = 1
! 246: factorial(2) = 2
! 247: factorial(3) = 6
! 248: factorial(4) = 24
! 249: (it should break at 5...)
! 250: factorial(0) = 1
! 251: factorial(1) = 1
! 252: factorial(2) = 2
! 253: factorial(3) = 6
! 254: factorial(4) = 24
! 255: (it should break at 5...)
! 256: factorial(0) = 1
! 257: factorial(1) = 1
! 258: factorial(2) = 2
! 259: factorial(3) = 6
! 260: factorial(4) = 24
! 261: (it should break at 5...)
! 262: factorial(0) = 1
! 263: factorial(1) = 1
! 264: factorial(2) = 2
! 265: factorial(3) = 6
! 266: factorial(4) = 24
! 267: (it should break at 5...)
! 268: factorial(0) = 1
! 269: factorial(1) = 1
! 270: factorial(2) = 2
! 271: factorial(3) = 6
! 272: factorial(4) = 24
! 273: (it should break at 5...)
! 274: factorial(0) = 1
! 275: factorial(1) = 1
! 276: factorial(2) = 2
! 277: factorial(3) = 6
! 278: factorial(4) = 24
! 279: (it should break at 5...)
! 280: factorial(0) = 1
! 281: factorial(1) = 1
! 282: factorial(2) = 2
! 283: factorial(3) = 6
! 284: factorial(4) = 24
! 285: ------
! 286: 720
! 287: 840
! 288: 3
! 289: 4
! 290: 5
! 291:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>