The
fopen() filesystem function in PHP will open a file or URL, at which point you can read it, write to it, append to it, and perform similar actions to it once opened.
<?php
// Create the file handler
$fileHandler = fopen("myfile.txt", "w");
// Write to the file
fwrite($fileHandler, "Welcome to the show");
// Close the file handler
fclose($fileHandler);
// Access the file data and echo it
$data = file_get_contents("myfile.txt");
echo $data;
?>
Welcome to the show