What is the purpose of using fopen in PHP to read HTML files?
When working with HTML files in PHP, you can use the fopen function to open and read the contents of the file. This allows you to access the HTML content and manipulate it as needed within your PHP script. By using fopen, you can easily read the HTML file line by line or in its entirety, enabling you to extract specific data or perform actions based on the file's content.
$file = fopen("example.html", "r");
if ($file) {
while (!feof($file)) {
$line = fgets($file);
echo $line;
}
fclose($file);
} else {
echo "Unable to open file.";
}