PHP.nl

dio_seek

dio_seek

Seeks to pos on fd from whence

int **dio_seek** resource $fd int $pos int $whence

The function is used to change the file position of the given file descriptor.
dio_seek

fd The file descriptor returned by . dio_open

posThe new position.

whence Specifies how the position should be interpreted:

  `pos`- (default) - specifies that             is specified from the beginning of the            file.          `SEEK_SET``pos`
    • Specifies that is a count of characters from the current file position. This count may be positive or negative. SEEK_CUR``pos
    • Specifies that is a count of characters from the end of the file. A negative count specifies a position within the current extent of the file; a positive count specifies a position past the current end. If you set the position past the current end, and actually write data, you will extend the file with zeros up to that position. SEEK_END``pos

    Voorbeeld: Positioning in a file

<?php

$fd = dio_open('/dev/ttyS0', O_RDWR);

dio_seek($fd, 10, SEEK_SET);
// position is now at 10 characters from the start of the file

dio_seek($fd, -2, SEEK_CUR);
// position is now at 8 characters from the start of the file

dio_seek($fd, -5, SEEK_END);
// position is now at 5 characters from the end of the file

dio_seek($fd, 10, SEEK_END);
// position is now at 10 characters past the end of the file. 
// The 10 characters between the end of the file and the current
// position are filled with zeros.

dio_close($fd);
?>