note 129900 added to function.fseek

From: Date: Fri, 06 Dec 2024 07:07:04 +0000
Subject: note 129900 added to function.fseek
Groups: php.notes 
Request: Send a blank email to php-notes+get-221703@lists.php.net to get a copy of this message
WARNING: The return values for this function are backwards from what is expected in PHP! <?php if (!fseek($File_Handle, $Position)) { die("Could not seek in file."); } ?> This will die when it succeeds, and continue when it fails. This is because the return values for fseek() are backwards from other PHP functions. This function returns 0 (FALSE) on success, and -1 (TRUE) on failure. This needs a big red warning box similar to other functions that return FALSE on failure and 0 or above on success. I submitted a documentation issue. This works for checking for errors: <?php if (fseek($File_Handle, $Position) === -1) { die("Could not seek in file."); } ?> ---- Server IP: 45.112.84.4 Probable Submitter: 45.112.84.18 (proxied: 38.13.79.164) ---- Manual Page -- https://php.net/manual/en/function.fseek.php Edit -- https://main.php.net/note/edit/129900 Del: integrated -- https://main.php.net/note/delete/129900/integrated Del: useless -- https://main.php.net/note/delete/129900/useless Del: bad code -- https://main.php.net/note/delete/129900/bad+code Del: spam -- https://main.php.net/note/delete/129900/spam Del: non-english -- https://main.php.net/note/delete/129900/non-english Del: in docs -- https://main.php.net/note/delete/129900/in+docs Del: other reasons-- https://main.php.net/note/delete/129900 Reject -- https://main.php.net/note/reject/129900 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#221703) next »