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

From: Date: Sun, 10 Aug 2014 22:59:26 +0000
Subject: Re: what is the main difference between fread() and readfile()?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-323724@lists.php.net to get a copy of this message
Sincerely Negin Nickparsa On Sun, Aug 10, 2014 at 3:57 PM, Aziz Saleh <azizsaleh@gmail.com> wrote: > > > > On Sun, Aug 10, 2014 at 6:31 PM, Negin Nickparsa <nickparsa@gmail.com> > wrote: > >> fread >> (PHP 4, PHP 5) >> >> fread — Binary-safe file read >> Description ¶ >> < >> «¤6 >> h�?#$k£0LzEhttp://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). > ​so fread is reading the entire file?​

« previous php.general (#323724) next »