From 8befa0e8fef3a54a3226e3b8c3ebda3dcad9c7f8 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Thu, 29 May 2003 20:10:20 +0000 Subject: [PATCH] Revise docs a little; document the non-greedy fread semantics when reading from network streams and fifos. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@129235 c90b9560-bf6c-de11-be94-00142212c4b1 --- .../functions/file-get-contents.xml | 7 ++- reference/filesystem/functions/fopen.xml | 6 ++- reference/filesystem/functions/fread.xml | 44 ++++++++++++++++++- 3 files changed, 52 insertions(+), 5 deletions(-) diff --git a/reference/filesystem/functions/file-get-contents.xml b/reference/filesystem/functions/file-get-contents.xml index cb061fb336..9bc5637215 100644 --- a/reference/filesystem/functions/file-get-contents.xml +++ b/reference/filesystem/functions/file-get-contents.xml @@ -1,5 +1,5 @@ - + @@ -18,6 +18,11 @@ Identical to file, except that file_get_contents returns the file in a string. + + file_get_contents is the preferred way to read the + contents of a file into a string. It will use memory mapping techniques if + support by your OS to enhance performance. + ¬e.bin-safe; &tip.fopen-wrapper; diff --git a/reference/filesystem/functions/fopen.xml b/reference/filesystem/functions/fopen.xml index 147098dcfa..3a140ff22a 100644 --- a/reference/filesystem/functions/fopen.xml +++ b/reference/filesystem/functions/fopen.xml @@ -1,5 +1,5 @@ - + @@ -189,11 +189,13 @@ $handle = fopen ("c:\\data\\info.txt", "r"); See also , fclose, fgets, + fread, + fwrite, fsockopen, file, file_exists, is_readable, - socket_set_timeout, and + stream_set_timeout, and popen. diff --git a/reference/filesystem/functions/fread.xml b/reference/filesystem/functions/fread.xml index 3c284e2efe..9ae3528a45 100644 --- a/reference/filesystem/functions/fread.xml +++ b/reference/filesystem/functions/fread.xml @@ -1,5 +1,5 @@ - + @@ -36,12 +36,19 @@ fclose ($handle); + + If you just want to get the contents of a file into a string, use + file_get_contents as it has much better performance + than the code above. + + + On systems which differentiate between binary and text files (i.e. Windows) the file must be opened with 'b' included in fopen mode parameter. - + @@ -56,6 +63,39 @@ fclose ($handle); + + + + When reading from network streams or pipes, such as those returned when + reading remote files or from + popen and proc_open, reading + will stop after a packet is available. This means that you should + collect the data together in chunks as shown in the example below. + + + + + + +]]> + + + + + + See also fwrite, fopen, fsockopen, popen,