Doc #60464 [Csd]: fseek documention incorrect

From: Date: Thu, 08 Dec 2011 00:05:57 +0000
Subject: Doc #60464 [Csd]: fseek documention incorrect
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-7619@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=60464&edit=1 ID: 60464 Updated by: frozenfire@php.net Reported by: df1986 at aol dot com Summary: fseek documention incorrect Status: Closed Type: Documentation Problem Package: Filesystem function related Operating System: All PHP Version: Irrelevant Assigned To: frozenfire Block user comment: N Private report: N New Comment: Yeah, you're actually right mfonda. Looking back at the sources, that actually makes more sense. Normally when I see only two return statements it's a "false on failure" situation, but in this case I suppose the RETURN_LONG would provide different results based on the internal function it calls. I'll revert my change. Previous Comments: ------------------------------------------------------------------------ [2011-12-07 23:56:49] mfonda@php.net I think the docs were actually correct here. fseek will return -1 if the seek fails, and 0 upon success. It will return false in the case of invalid arguments, such as the example below. ------------------------------------------------------------------------ [2011-12-07 23:34:11] frozenfire@php.net This bug has been fixed in SVN. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. For Windows: http://windows.php.net/snapshots/ Thank you for the report, and for helping us make PHP better. By the way, don't use json_encode for debugging. It's bound to screw you up. Use var_dump instead. ------------------------------------------------------------------------ [2011-12-07 23:33:32] frozenfire@php.net Automatic comment from SVN on behalf of frozenfire Revision: http://svn.php.net/viewvc/?view=revision&revision=320620 Log: Fixed return value. Closed bug #60464. ------------------------------------------------------------------------ [2011-12-07 22:05:05] df1986 at aol dot com Description: ------------ --- From manual page: http://www.php.net/function.fseek#refsect1-function.fseek-returnvalues --- Docs say fseek returns -1 on error, actually returns false. Test script: --------------- //Invalid resource echo json_encode(fseek('', 52));//outputs false //Dangling resource $f = fopen('somefile', 'r');//to get a valid resource fclose($f);//to make it dangle echo json_encode(fseek($f, 52));//outputs false ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=60464&edit=1

« previous php.doc.bugs (#7619) next »