Re: what is the main difference between fread() and readfile()?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Aug 10, 2014 at 6:31 PM, Negin Nickparsa <nickparsa@xxxxxxxxx>
wrote:

> fread
> (PHP 4, PHP 5)
>
> fread — Binary-safe file read
> Description ¶
> <
> http://us1.php.net/manual/en/function.fread.php#refsect1-function.fread-description
> >
> string fread ( resource $handle , int $length )
>
> fread() reads up to length bytes from the file pointer referenced by
> handle.
> Reading stops as soon as one of the following conditions is met:
> readfile
>
> (PHP 4, PHP 5)
>
> readfile — Outputs a file
> Description ¶
> <
> http://us3.php.net/manual/en/function.readfile.php#refsect1-function.readfile-description
> >
> int readfile ( string $filename [, bool $use_include_path = false [,
> resource $context ]] )
>
> Reads a file and writes it to the output buffer.
>
> in which condition it's better to use them? I confronted a question that is
> asking which of the following functions reads the entire contents of a
> file?
>
> A.fgets
>
> B.file_get_contents
>
> C.fread()
>
> D.readfile()
>
> E.file()
>
> in my opinion the answer is B,C,D,E
>
> but the answer key is telling me the answer is B,D,E so fread for some
> reason is not the answer and I cannot understand.
>
> *john coggshall and Marco Tabini  test book*
>

file_get_contents, file, and readfile all take the filename location as
oppose to fgets/fread which require file pointers - requiring you to open
the file first (via fopen for example).

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux