fopen()

fopen() is a PHP native function which opens a file. It returns a file description, also called handle, that may be used with other PHP file functions to read and write data from and to the files.

fopen() may also be replaced by the SplFileObject class, which provides a OOP syntax alternative to access files.

<?php

    $fp = fopen('/tmp/test.txt', 'r');
    fwrite($fp, 'PHP rocks!');
    fclose($fp);

?>

Documentation

See also PHP Open File.

Related : File, Writing, Permission, Writeable, Readable, SplFileObject, $http_response_header, File Mode, Resource Leak, Text, Handle, Universal Resource Locator (URL)