fopen()
` - Used to open a file and returns a file pointer resourcefread()
` - Used to read content from the filefclose()
` - Used to close the file and release resources<?php
$file = fopen("example.txt", "r") or die("Unable to open file!"); // open the file in read mode
$content = fread($file, filesize("example.txt")); // read the content from the file
echo $content; // display the content of the file
fclose($file); // close the file
?>
example.txt
" in read mode using the `fopen()
` function. Then we read the content of the file using the `fread()
` function and stored it in the variable `$content
`. echo
` statement and closed the file using the `fclose()
` function.