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 an OOP syntax alternative to access files.
<?php
$fp = fopen('/tmp/test.txt', 'r');
fwrite($fp, 'PHP rocks!');
fclose($fp);
?>