★ wanayoo — archive 1999 http://www.php.net/manual/function.readfile.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to Filesystem
Quick Reference
German version of this pageJapanese version of this pageItalian version of this pageFrench version of this pageHungarian version of this page
Filesystem
* basename
* chgrp
* chmod
* chown
* clearstatcache
* copy
* delete
* dirname
* diskfreespace
* fclose
* feof
* fgetc
* fgetcsv
* fgets
* fgetss
* file
* file_exists
* fileatime
* filectime
* filegroup
* fileinode
* filemtime
* fileowner
* fileperms
* filesize
* filetype
* flock
* fopen
* fpassthru
* fputs
* fread
* fscanf
* fseek
* fstat
* ftell
* ftruncate
* fwrite
* set_file_buffer
* is_dir
* is_executable
* is_file
* is_link
* is_readable
* is_writeable
* link
* linkinfo
* mkdir
* pclose
* popen
* readfile
* readlink
* rename
* rewind
* rmdir
* stat
* lstat
* realpath
* symlink
* tempnam
* touch
* umask
* unlink
Manual: readfile
View the source code for this pageSearch the site



Previous page
 popen
 Updated
Sat, 12 Aug 2000
readlink 
Next page


readfile

(PHP3 , PHP4 )

readfile -- Output a file

Description

int readfile (string filename [, int use_include_path])

Reads a file and writes it to standard output.

Returns the number of bytes read from the file. If an error occurs, false is returned and unless the function was called as @readfile, an error message is printed.

If filename begins with "http://" (not case sensitive), an HTTP 1.0 connection is opened to the specified server and the text of the response is written to standard output.

Does not handle HTTP redirects, so you must include trailing slashes on directories.

If filename begins with "ftp://" (not case sensitive), an ftp connection to the specified server is opened and the requested file is written to standard output. If the server does not support passive mode ftp, this will fail.

If filename begins with neither of these strings, the file will be opened from the filesystem and its contents written to standard output.

You can use the optional second parameter and set it to "1", if you want to search for the file in the include_path, too.

See also fpassthru(), file(), fopen(), include(), require(), and virtual().


User Contributed Notes: readfile


jurrit@home.nl
08-Mar-2000 08:49
This is actually more a question, but I will ask it any way.
I made a php3 script that pulls data from a MySQL database and puts it on the screen. Is it possible, to save what is on the screen, to a text file? Now I just click on the browsers save as.. function. But I want to automate this procedure.

Thanx in advance.

Jurrit



robert@abilina.org
15-Mar-2000 11:21
If you are using this function to read a remote server's page and the URL requires a cookie, there appears to be no way to read it using this function. It would be very nice if this were supported.


jason@familynet.net
15-May-2000 10:39
If you use readfile() to pull down HTML from an http:// source, is there a way to handle connection timeouts? For example, if the http server we are attempting to read from is down, how do you it it up to do something else (or even display an error)?


hicking@du.gtn.com
22-May-2000 09:21
You might want to try checking the $php_errormsg variable after calling readfile(...). To supress errormessages to your client's browser you could also add @ before readfile(...). Make sure you have track_errors enabled in your php configuration. See <A HREF=/old?u=http%3A%2F%2Fwww.php.net%2Fmanual%2Flanguage.operators.errorcontrol.php%26gt%3BError&y=1999 Control</A> in the manual.


 About Notes


Previous page
 popen
 Updated
Sat, 12 Aug 2000
readlink 
Next page





Who's responsible for this?
Top of this page

Site
Hosting:



Located in
United States
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.