1--TEST-- 2Test fseek() function : usage variations - different types for whence 3--CREDITS-- 4Dave 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 13echo "*** Testing fseek() : usage variations ***\n"; 14error_reporting(E_ALL & ~E_NOTICE); 15$fp = fopen(__FILE__, 'r'); 16$offset = 3; 17 18//get an unset variable 19$unset_var = 10; 20unset ($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 63foreach($values as $value) { 64 echo "\nArg value $value \n"; 65 var_dump( fseek($fp, $offset, $value) ); 66 var_dump( ftell($fp)); 67}; 68 69fclose($fp); 70echo "Done"; 71?> 72--EXPECTF-- 73*** Testing fseek() : usage variations *** 74 75Arg value -100 76int(-1) 77int(0) 78 79Arg value 100 80int(-1) 81int(0) 82 83Arg value 10.5 84int(-1) 85int(0) 86 87Arg value -10.5 88int(-1) 89int(0) 90 91Arg value 101234567000 92int(-1) 93int(0) 94 95Arg value 1.07654321E-9 96int(0) 97int(3) 98 99Arg value 0.5 100int(0) 101int(3) 102 103Arg value 104int(0) 105int(3) 106 107Arg value 108int(0) 109int(3) 110 111Arg value 1 112int(0) 113int(6) 114 115Arg value 116int(0) 117int(3) 118 119Arg value 1 120int(0) 121int(6) 122 123Arg value 124int(0) 125int(3) 126 127Arg value 128 129Warning: fseek() expects parameter 3 to be long, string given in %s on line %d 130bool(false) 131int(3) 132 133Arg value 134 135Warning: fseek() expects parameter 3 to be long, string given in %s on line %d 136bool(false) 137int(3) 138 139Arg value string 140 141Warning: fseek() expects parameter 3 to be long, string given in %s on line %d 142bool(false) 143int(3) 144 145Arg value string 146 147Warning: fseek() expects parameter 3 to be long, string given in %s on line %d 148bool(false) 149int(3) 150 151Arg value 152int(0) 153int(3) 154 155Arg value 156int(0) 157int(3) 158Done 159 160