Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

ftell(3) [php man page]

FTELL(3)								 1								  FTELL(3)

ftell - Returns the current position of the file read/write pointer

SYNOPSIS
int ftell (resource $handle) DESCRIPTION
Returns the position of the file pointer referenced by $handle. PARAMETERS
o $handle - The file pointer must be valid, and must point to a file successfully opened by fopen(3) or popen(3). ftell(3) gives undefined results for append-only streams (opened with "a" flag). RETURN VALUES
Returns the position of the file pointer referenced by $handle as an integer; i.e., its offset into the file stream. If an error occurs, returns FALSE. Note Because PHP's integer type is signed and many platforms use 32bit integers, some filesystem functions may return unexpected results for files which are larger than 2GB. EXAMPLES
Example #1 ftell(3) example <?php // opens a file and read some data $fp = fopen("/etc/passwd", "r"); $data = fgets($fp, 12); // where are we ? echo ftell($fp); // 11 fclose($fp); ?> SEE ALSO
fopen(3), popen(3), fseek(3), rewind(3). PHP Documentation Group FTELL(3)

Check Out this Related Man Page

REWIND(3)								 1								 REWIND(3)

rewind - Rewind the position of a file pointer

SYNOPSIS
bool rewind (resource $handle) DESCRIPTION
Sets the file position indicator for $handle to the beginning of the file stream. Note If you have opened the file in append ("a" or "a+") mode, any data you write to the file will always be appended, regardless of the file position. PARAMETERS
o $handle - The file pointer must be valid, and must point to a file successfully opened by fopen(3). RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 rewind(3) overwriting example <?php $handle = fopen('output.txt', 'r+'); fwrite($handle, 'Really long sentence.'); rewind($handle); fwrite($handle, 'Foo'); rewind($handle); echo fread($handle, filesize('output.txt')); fclose($handle); ?> The above example will output something similar to: Foolly long sentence. SEE ALSO
fread(3), fseek(3), ftell(3), fwrite(3). PHP Documentation Group REWIND(3)
Man Page

4 More Discussions You Might Find Interesting

1. Programming

Need help with ftell() function ..

Hello friends, I need help with ftell function in my programme, I can't figure out why I am not getting the file position what I supposed to get Here is my code void read_line(void *fh, double *input_re, double *input_im){ double a, b; char s; int n; ... (3 Replies)
Discussion started by: user_prady
3 Replies

2. Programming

fread: segementation fault(coredump) w/o stdlib.h

Hello All, I tried to test a sample fread example to read a complete file and the code is #include <stdio.h> #include <stdlib.h> int main () { FILE * pFile; long lSize; char * buffer; size_t result; pFile = fopen ( "test.xml" , "rb" ); if (pFile==NULL) {fputs ("File... (11 Replies)
Discussion started by: quintet
11 Replies

3. Shell Programming and Scripting

Mac. PHP fopen() does not create a file. Permissions.

5Thank you to those who responded. After a crazy amount of troubleshooting and getting hints and feedback from others, I was so darn determined to get on with my tutorials and I found the solution myself. Keyword search: php and 'Mac computer' and fopen and chmod. Using:php and Mac and... (1 Reply)
Discussion started by: iHaveAQuestion
1 Replies

4. Web Development

Mac. PHP. fopen( ) does not create a file. Permissions.

Thank you to those who responded. After a crazy amount of troubleshooting and getting hints and feedback from others, I was so darn determined to get on with my tutorials and I found the solution myself. Keyword search: php and 'Mac computer' and fopen and chmod. Using: php and Mac and... (2 Replies)
Discussion started by: iHaveAQuestion
2 Replies