On Wed, 15 May 2002, arnaud gonzales wrote:
> I'm newbie in php and i would like to clearly understand how can i use:
>   LENGTH  in   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). If no
> length is specified, the length defaults to 1k, or 1024 bytes."
> -Can i have an example of the differents way for reading file with fgets
> according to the      differentes values of "length "?
> -why '4096' is used as length for reading a file line by line ?
>               $fd = fopen ("/tmp/inputfile.txt", "r");
>               while (!feof ($fd)) {
>                $buffer = fgets($fd, 4096);
>                echo $buffer;
>               }
>               fclose ($fd);
> Is this any max for one line??

The idea is to avoid runaway reads. This way if you get pointed to a file 
that's a link to /dev/random, you won't blow through all your memory and 


PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to