Home >Backend Development >PHP Problem >How to use php rewind function

How to use php rewind function

青灯夜游
青灯夜游Original
2019-05-28 15:24:282743browse

The rewind() function is a built-in function in PHP that is used to set the position of the file pointer to the beginning of the file. The syntax is rewind(file), and if successful, the function returns TRUE. On failure, returns FALSE.

How to use php rewind function

#php How to use the rewind() function?

php The rewind() function rewinds the position of the file pointer back to the beginning of the file.

Syntax:

rewind(file)

Parameters: The rewind() function accepts one parameter.

● File: required. Specifies an open file.

Return value: If successful, this function returns TRUE. On failure, returns FALSE.

Description: The rewind() function generates an E_WARNING level error when it fails. If the file is opened in append mode, the data written will be appended regardless of the position of the pointer.

php rewind() function example

<?php
$file = fopen("test.txt","r");
//更改文件指针的位置
fseek($file,"15");
//将文件指针设置为0
rewind($file);
fclose($file);
?>

The above is the detailed content of How to use php rewind function. 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