Hacking with PHP has been updated for PHP 7 - click here! >>

Creating and changing files

Like reading files, creating and changing files can also be done in more than one way. Luckily for you, there are just two options this time: file_put_contents() and fwrite(). Both of these functions complement functions we just looked at, which are file_get_contents() and fread() respectively, and they work in mostly the same way.


If this was helpful, please take a moment to tell others about Hacking with PHP by tweeting about it!

Next chapter: file_put_contents() >>

Previous chapter: fopen() and fread()

Jump to:


Home: Table of Contents

Copyright ©2015 Paul Hudson. Follow me: @twostraws.