File Handling

<?php
$file = fopen("example.txt", "w");
fwrite($file, "Hello File Handling!");
fclose($file);

$file = fopen("example.txt", "r");
echo fread($file, filesize("example.txt"));
fclose($file);
?>

Explanation:

  • "w" → write mode (creates/overwrites file).
  • "r" → read mode.
  • fwrite writes text into file, fread reads it.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *