Writing to a File

Contact Us or call 1-877-932-8228
Writing to a File

Writing to a File

Opening a file for writing involves three steps:

  1. Open the file.
  2. Write to the file.
  3. Close the file.

fwrite()

Syntax

fwrite(file_pointer,output_string)

The output_string is the text to write to the file. See the following example of writing to a file.

$outputString='text to write';
$myFile = @fopen('Employees.txt', 'a');
fwrite($myFile, $outputString);
fclose($myFile);
Next