Skip to content

Instantly share code, notes, and snippets.

@phpfiddle
Created December 31, 2017 02:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phpfiddle/a3d07a6e047a2ed77319b1d8c0b295de to your computer and use it in GitHub Desktop.
Save phpfiddle/a3d07a6e047a2ed77319b1d8c0b295de to your computer and use it in GitHub Desktop.
[ Posted by Jonathan Klemm ] Example 7-4
<?php // testfile.php
$fh = fopen("testfile.txt", 'w') or die("Failed to create a file");
$text = <<<_END
Line 1
Line 2
Line 3
_END;
fwrite($fh, $text) or die("Could not write to file");
fclose($fh);
echo "File 'testfile.txt' written successfully";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment