rewind() function in PHP


The rewind() function rewinds a file pointer. It moves it to the beginning of the file. It returns True on success or False on failure.

Syntax

rewind(file_pointer)

Parameters

  • file_pointer − It must point to a file opened by fopen()

Return

The rewind() function returns True on success or False on failure.

Example

$file_pointer = fopen("new.txt", "r");
// Position of the file pointer is changed
fseek($file_pointer, "12");
// Setting the file pointer to the beginning of the file
rewind($file_pointer);
fclose($file_pointer);

Output

TRUE

Updated on: 30-Jul-2019

78 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements