note 8377 modified in function.fgets by irc-html

From: Date: Tue, 22 Jan 2002 23:06:47 +0000
Subject: note 8377 modified in function.fgets by irc-html
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-25711@lists.php.net to get a copy of this message
A common mistake is given in the previous example. That is, if the string you're searching for occurs over a boundary (in this case, of 4k). For example, if the word "hello" were found starting at the 8th character and I read 10 characters, "hello" would not be found. If I read the next 10 characters, "hello" would again not be found (although "llo" would be). One solution is to always increment your buffer by BUFFER_SIZE - (SEARCH_STR_LEN-1). That will make sure your search string shows up. $i = 0; $search = "hello"; (loop while not eof ...) $i += 4096 - (strlen($search) - 1); --was-- A common mistake is given in the previous example. That is, if the string you're searching for occurs over a boundary (in this case, of 4k). For example, if the word "hello" were found starting at the 8th character and I read 10 characters, "hello" would not be found. If I read the next 10 characters, "hello" would again not be found (although "llo" would be). One solution is to always increment your buffer by BUFFER_SIZE - (SEARCH_STR_LEN-1). That will make sure your search string shows up. <PRE> $i = 0; $search = "hello"; (loop while not eof ...) $i += 4096 - (strlen($search) - 1); http://www.php.net/manual/en/function.fgets.php

« previous php.notes (#25711) next »