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.
#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!