Actually, this is a valid question and isn't addressed in the manual; Some systems use an internal buffer of a particular length that effectively limits the maximum chunk that you can read in one call. This is problematic, particularly for fgets where you are only interested in lines.
There are a couple of workarounds; one is to use fread and look for linebreaks manually, and the other is to use file() - but if you have lines longer than 8k that implies that you have a big file so file() would most likely chew up a load of memory. The best thing is to actually fix fgets to handle very long lines; well, if you are working from local files - tough luck - the limit is imposed by your system fgets() call. If you are sucking the file over a socket, fgets is emulated by PHP and *should* work for long lines (Winsock has a buffer limit of 8K, but we cache the data in our own struct). We could potentially fix this in PHP 4.3, but that would mean implementing our own buffering layer in streams; that introduces complexities when it comes to passing the stream to a third-party library which is why it has been avoided up until now (and probably won't be dealt with until PHP 5, *if* we do deal with it). I hope that helps; it would be useful if you could verify what exactly if happening and let us know which platform/OS you are using, and more importantly, the PHP version you are using (a lot has changed for fgets and friends in the CVS version). --Wez. On 06/09/02, "Alan Knowles" <[EMAIL PROTECTED]> wrote: > Please use the php-general for questions like this. > > - see http://www.php.net/fread > > Regards > Alan > > Terence Lee wrote: > > >hello > > > >i've tried to read a line from a text file by fgets($fp,8192). it work > >fine. however, there is a line over 8192 char and i tried to increase > >the 2nd parameter (e.g. 8193, 16384, 88192) still only 8192 char are > >read to my string variables. > > > >is it a limit of fgets or length of a string? any way to achieve getting > >more than 8192 char from a line in a text file? > > > >pls advice. > > > >terence > > > > > > > > > > > > > > > -- > PHP Development Mailing List <http://www.php.net/> > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php