- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
fseek() function in PHP
The fseek() function seeks in an open file. It returns 0 on success, else returns -1 on failure.
Syntax
fseek(file_pointer, offset, whence)
Parameters
file_pointer − A file pointer created using fopen(). Required.
offset − Specify the new position. Required.
whence − The following are the values:
- SEEK_SET - Set position equal to offset bytes. Default.
- SEEK_CUR - Set position to current location plus offset.
- SEEK_END - Set position to end-of-file plus offset.
Return
The fseek() function returns 0 on success, else returns -1 on failure.
Example
<?php $file_pointer = fopen("new.txt", "w"); fgets($file_pointer); // move back to the beginning of file echo fseek($file_pointer, 0); fclose($myfile); ?>
Output
0
Advertisements