php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #72804 docs on rewind explicitly says it must be opened by fopen()
Submitted: 2016-08-10 13:25 UTC Modified: 2016-08-10 21:13 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: divinity76 at gmail dot com Assigned:
Status: Open Package: Filesystem function related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
45 - 21 = ?
Subscribe to this entry?

 
 [2016-08-10 13:25 UTC] divinity76 at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.rewind
---
quote: The file pointer must be valid, and must point to a file successfully opened by fopen().

rewind also works fine on files opened by tmpfile(), so at the very least, the docs should say "opened by fopen() or tmpfile()", if there isn't more. (PS: there is a similar problem with the docs for "ftell")

Test script:
---------------
<?php
$h=tmpfile();
var_dump(ftell($h));
fwrite($h,'PHP');
var_dump(ftell($h));
rewind($h);
var_dump(ftell($h));


Expected result:
----------------
int(0)
int(3)
int(3)

Actual result:
--------------
int(0)
int(3)
int(0)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-08-10 21:13 UTC] requinix@php.net
-Package: Documentation problem +Package: Filesystem function related
 [2016-08-10 21:13 UTC] requinix@php.net
It works on all streams (that support seeking).

fclose, feof, fflush... It looks like most of the functions specifically call out fopen or fsockopen. Given how prevalent streams are, could they warrant their own pseudotype in the manual?
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed Nov 25 09:01:23 2020 UTC