Created
January 15, 2026 23:23
-
-
Save maxixo/c8523fd806bcef2463d3a7e5257929cb to your computer and use it in GitHub Desktop.
Reading and writing to files in php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // WRITE to file | |
| $handle = fopen("example.txt", "w"); | |
| fwrite($handle, "Hello, this is a test \n"); | |
| fwrite($handle, "We are writing to a file in PHP"); | |
| fclose($handle); | |
| // READ from file | |
| $handle = fopen("example.txt", "r"); | |
| $content = fread($handle, filesize("example.txt")); | |
| fclose($handle); | |
| echo $content; | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment