User Tools

Site Tools


uphp:functions:ftell

This is an old revision of the document!


ftell

WMPRO, WMMINI FW >= 1.0 WMMEGA FW >= 2.0

Position the file pointer in an open file

Description

ftell ( int $handle, int $offset, int $whence )

This function will relocate the file pointer within an active file. Three different start position options are available.

Parameters

$handle: Valid handle of a previously opened resource

$offset: How far to move the pointer (bytes)

$whence: Seek type, starting position option, from where to move the pointer:

  • 0 - Seek from the start of the file
  • 1 - Seek from the current position
  • 2 - Seek from the end of the file (in reverse)

Return Values

None

Example

<?
  $fp=fopen("/index.cgi","r");
  if ($fp) {
    fseek($fp,10,2); // position to 10 characters before the end of the file
    $data=fread($fp,10);
    print($data);
    fclose($fp);
  } else {
    print("File open failed\n");
  }
?>

See Also

fopen() - Open a file for reading or writing

fread() - Return bytes from a file or stream

fgets() - Return a single line from a file or stream, with optional size limit

fwrite() - Write data to a file or stream

fclose() - Close a file, stream or socket

uphp/functions/ftell.1490967808.txt.gz · Last modified: 2021/09/13 05:56 (external edit)