How can PHP be used to read and manipulate the contents of an HTML file?
To read and manipulate the contents of an HTML file using PHP, you can use the file_get_contents() function to read the file into a string variable. You can then use string manipulation functions like str_replace() or preg_replace() to modify the HTML content as needed. Finally, you can use file_put_contents() function to write the modified content back to the HTML file.
<?php
// Read the contents of the HTML file into a string variable
$html = file_get_contents('example.html');
// Manipulate the HTML content as needed
$html = str_replace('old_text', 'new_text', $html);
// Write the modified content back to the HTML file
file_put_contents('example.html', $html);
?>