In PHP, the rewind() function method is used to rewind the position of the file pointer to the beginning of the file. If the position of the pointer is rewinded successfully, the result returned by this function is true. If the position of the pointer is rewinded, If the return is unsuccessful, the return result of this function is false, and the syntax is "rewind (specifies the opened file)".
The operating environment of this article: Windows 10 system, PHP version 8.1, Dell G3 computer
rewind() function rewinds the position of the file pointer to the beginning of the file.
If successful, this function returns TRUE. On failure, returns FALSE.
Syntax
rewind(file)
Parameter Description
file Required. Specifies an open file.
Examples are as follows:
<?php $file = fopen("test.txt","r"); //改变文件指针的位置 fseek($file,"15"); //把文件指针设定为 0 rewind($file); fclose($file); ?>
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to use the rewind method in traversal in PHP class. For more information, please follow other related articles on the PHP Chinese website!