Home  >  Article  >  Backend Development  >  How to use the rewind method in traversal in PHP class

How to use the rewind method in traversal in PHP class

WBOY
WBOYOriginal
2022-06-23 16:38:021680browse

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)".

How to use the rewind method in traversal in PHP class

The operating environment of this article: Windows 10 system, PHP version 8.1, Dell G3 computer

The rewind method in the traversal in the php class

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn