How to use the rewind method in traversal in PHP class

WBOY
Release: 2023-03-16 12:06:02
Original
1699 people have browsed it

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)
Copy after login

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);
?>
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template