Re: fgets($fp, 4096); What does the 4096
| From: | David Robley | Date: | Thu, 26 Oct 2000 01:34:20 +0000 |
| Subject: | Re: fgets($fp, 4096); What does the 4096 | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-21995@lists.php.net to get a copy of this message | ||
On Tue, 24 Oct 2000, Joe Joe wrote:
> Sorry to interrupt a bit...I'm still don't
> undertsand..."maximum size of string read"....how to
> count the size...I mean is it in bytes..??..
>
> I got some code as below....Will it come to a maximum
> size where the code cannot read...??..If so, is there
> any way to solve the problem..??.
>
> $fd = fopen($file,"r");
> while (!feof ($fd)) {
> $buffer = fgets($fd,4096);
> return $buffer;
> }
> fclose ($fd);
> Thanx...
From the manual
string fgets (int fp, int length)
Returns a string of up to length - 1 bytes read from the file pointed to
by fp. Reading ends when length - 1 bytes have been read, on a newline
(which is included in the return value), or on EOF (whichever comes
first).
So, if the string in your case is longer than 4095 it will be truncated.
Solution: use a really big number. Or alternatively you might find that
file() will do what you want.
--
David Robley | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/
AusEinet | http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA