fopen

resource fopen(string filename, string mode) 

Opens a file.

Returns:

File handle

Description:

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:

Mode String Function
r Read only
r+ Read and write, preserves file contents (overwrites existing content on write operations)

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.