Return to fseek_variation2.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / file |
1.1 misho 1: --TEST-- 2: Test fseek() function : usage variations - different types for whence 3: --CREDITS-- 4: Dave Kelsey <d_kelsey@uk.ibm.com> 5: --FILE-- 6: <?php 7: /* Prototype : proto int fseek(resource fp, int offset [, int whence]) 8: * Description: Seek on a file pointer 9: * Source code: ext/standard/file.c 10: * Alias to functions: gzseek 11: */ 12: 13: echo "*** Testing fseek() : usage variations ***\n"; 14: error_reporting(E_ALL & ~E_NOTICE); 15: $fp = fopen(__FILE__, 'r'); 16: $offset = 3; 17: 18: //get an unset variable 19: $unset_var = 10; 20: unset ($unset_var); 21: 22: //array of values to iterate over 23: $values = array( 24: 25: // outside of whence range 26: -100, 27: 100, 28: 29: // float data 30: 10.5, 31: -10.5, 32: 10.1234567e10, 33: 10.7654321E-10, 34: .5, 35: 36: // null data 37: NULL, 38: null, 39: 40: // boolean data 41: true, 42: false, 43: TRUE, 44: FALSE, 45: 46: // empty data 47: "", 48: '', 49: 50: // string data 51: "string", 52: 'string', 53: 54: // undefined data 55: $undefined_var, 56: 57: // unset data 58: $unset_var, 59: ); 60: 61: // loop through each element of the array for whence 62: 63: foreach($values as $value) { 64: echo "\nArg value $value \n"; 65: var_dump( fseek($fp, $offset, $value) ); 66: var_dump( ftell($fp)); 67: }; 68: 69: fclose($fp); 70: echo "Done"; 71: ?> 72: --EXPECTF-- 73: *** Testing fseek() : usage variations *** 74: 75: Arg value -100 76: int(-1) 77: int(0) 78: 79: Arg value 100 80: int(-1) 81: int(0) 82: 83: Arg value 10.5 84: int(-1) 85: int(0) 86: 87: Arg value -10.5 88: int(-1) 89: int(0) 90: 91: Arg value 101234567000 92: int(-1) 93: int(0) 94: 95: Arg value 1.07654321E-9 96: int(0) 97: int(3) 98: 99: Arg value 0.5 100: int(0) 101: int(3) 102: 103: Arg value 104: int(0) 105: int(3) 106: 107: Arg value 108: int(0) 109: int(3) 110: 111: Arg value 1 112: int(0) 113: int(6) 114: 115: Arg value 116: int(0) 117: int(3) 118: 119: Arg value 1 120: int(0) 121: int(6) 122: 123: Arg value 124: int(0) 125: int(3) 126: 127: Arg value 128: 129: Warning: fseek() expects parameter 3 to be long, string given in %s on line %d 130: bool(false) 131: int(3) 132: 133: Arg value 134: 135: Warning: fseek() expects parameter 3 to be long, string given in %s on line %d 136: bool(false) 137: int(3) 138: 139: Arg value string 140: 141: Warning: fseek() expects parameter 3 to be long, string given in %s on line %d 142: bool(false) 143: int(3) 144: 145: Arg value string 146: 147: Warning: fseek() expects parameter 3 to be long, string given in %s on line %d 148: bool(false) 149: int(3) 150: 151: Arg value 152: int(0) 153: int(3) 154: 155: Arg value 156: int(0) 157: int(3) 158: Done 159: