As you have learned from elsewhere in the book, the UNIX philosophy is that everything is a file. In PHP, this is also the case: A selection of basic file functions is suitable for opening and manipulating files, but those same functions can also be used for opening and manipulating network sockets. We cover both here.
Two basic read and write functions for files make performing these basic operations easy. They are
file_get_contents(), which takes a filename as its only parameter and returns the file’s contents as a string, and
file_put_contents(), which takes a filename as its first parameter and the data to write as its second parameter.
Using these two, you can write a script that reads all the text from one file,
filea.txt, and writes ...