fseek
Positioning in file pointer
fseek()
function is located in the open file.
This function moves the file pointer forward or backward from the current position to a new position, which starts at the file header by the number of bytes.
If successful, return 0; otherwise, return -1. Note that no error occurs when moving to the position after EOF.
<?php $file = fopen ( "test.txt" , "r" ) ; // Read the first line fgets ( $file ) ; // Rewind back to the beginning of the file fseek ( $file , 0 ) ; ?>
fseek ( file , offset , when )
parameter | describe |
---|---|
file | Required. Specify the files to be located in it. |
offset | Required. Specifies a new location (measured by bytes starting from the file header). |
when | Optional. Possible values:
|
Whence parameter is added after PHP 4.0.0.