How can the PHP filesystem functions be used to manipulate text files effectively?
To manipulate text files effectively using PHP filesystem functions, you can use functions like file_get_contents() to read the contents of a file, file_put_contents() to write to a file, and fopen(), fwrite(), and fclose() for more advanced file manipulation tasks.
// Read the contents of a text file
$contents = file_get_contents('example.txt');
// Write to a text file
file_put_contents('example.txt', 'Hello, World!');
// Open a file for writing, write to it, and close it
$file = fopen('example.txt', 'w');
fwrite($file, 'Hello, World!');
fclose($file);