note 92342 added to function.fgets

From: Date: Mon, 20 Jul 2009 17:49:11 +0000
Subject: note 92342 added to function.fgets
Groups: php.notes 
Request: Send a blank email to php-notes+get-158516@lists.php.net to get a copy of this message
As I noted in a comment on stream_get_line() page, fgets is *not* necessarily slower than stream_get_line(). In my case, it's actually ~2.5 times slower. (25 seconds vs 10 seconds) Also, stream_get_line() doesn't return the limiter. Since you pass both a maximum string length, you have no way of knowing whether or not the limiter was present in the original file, other than the 1 in 1024 chance that the line (with limiter) is exactly 1024 characters long, and appending the limiter (EG: "\n") in the case where the line is less than 1024 chars. This latter bit compromises data integrity, stream_get_line() should probably not be used for all but very special cases. ---- Server IP: 64.71.164.2 Probable Submitter: 76.193.72.245 ---- Manual Page -- http://www.php.net/manual/en/function.fgets.php Edit -- https://master.php.net/note/edit/92342 Del: integrated -- https://master.php.net/note/delete/92342/integrated Del: useless -- https://master.php.net/note/delete/92342/useless Del: bad code -- https://master.php.net/note/delete/92342/bad+code Del: spam -- https://master.php.net/note/delete/92342/spam Del: non-english -- https://master.php.net/note/delete/92342/non-english Del: in docs -- https://master.php.net/note/delete/92342/in+docs Del: other reasons-- https://master.php.net/note/delete/92342 Reject -- https://master.php.net/note/reject/92342 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#158516) next »