fopen() opens a file on the current system and positions the file pointer at the beginning of the file. If PHP has been configured to be URL-aware, prefixing the filename with either http:// or ftp:// opens a connection to the specified URL and returns the contents of the specified file. HTTP requests are not redirected, so any requests to a directory must have a trailing slash appended and FTP connections must be made to servers with support for passive mode transfers. The mode strings can be one of the following:
You cannot write to a URL.
3.0.7: Doesn't always work with URLs on Red Hat Linux 5.2. Reported to crash sometimes or make PHP return empty documents when using local files on Red Hat Linux 5.9.
3.0.8: Sometimes causes PHP to crash when using URLs on Linux 2.0.35. Subsequent fopen() or fclose() calls won't work on URLs on Solaris 2.6.
3.0.9: Reported not to work with HTTP files on Linux. Doesn't reliably work when supplying username/password information in URLs on Linux
3.0.10: Simply trying to open the file "http://" crashes PHP on Linux and Windows.
3.0.11: Might hang on Windows after reading more than 511 characters from a URL. Reported problems with URL wrappers again.
3.0.12: Might segfault with a certain compilation combination of Apache/PHP on Red Hat Linux 5.2.
PHP Functions Essential Reference. Copyright © 2002 by New Riders Publishing (Authors: Zak Greant, Graeme Merrall, Torben Wilson, Brett Michlitsch). This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at http://www.opencontent.org/openpub/). The authors of this book have elected not to choose any options under the OPL. This online book was obtained from http://www.fooassociates.com/phpfer/ and is designed to provide information about the PHP programming language, focusing on PHP version 4.0.4 for the most part. The information is provided on an as-is basis, and no warranty or fitness is implied. All persons and entities shall have neither liability nor responsibility to any person or entity with respect to any loss or damage arising from the information contained in this book.