dio_seek
(PHP 4 >= 4.2.0, PHP 5 < 5.1.0)
dio_seek — Seeks to pos on fd from whence
Description
$fd
, int $pos
[, int $whence
= SEEK_SET
] ) : intThe function dio_seek() is used to change the file position of the given file descriptor.
Parameters
-
fd
-
The file descriptor returned by dio_open().
-
pos
-
The new position.
-
whence
-
Specifies how the position
pos
should be interpreted:-
SEEK_SET
(default) - specifies thatpos
is specified from the beginning of the file. -
SEEK_CUR
- Specifies thatpos
is a count of characters from the current file position. This count may be positive or negative. -
SEEK_END
- Specifies thatpos
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.
-
Examples
Example #1 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);
?>
English translation
You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.
Thank you in advance.
Document created the 30/01/2003, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/php-rf-function.dio-seek.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.