O'Reilly logo

Programming PHP, 3rd Edition by Peter MacIntyre, Kevin Tatroe, Rasmus Lerdorf

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

file_put_contents

Synopsis

int file_put_contents(string path, mixed string [, int flags[, resource context]])

Opens the file specified by path, writes string to the file, then closes the file. Returns the number of bytes written to the file, or −1 on error. The flags argument is a bitfield with two possible values:

FILE_USE_INCLUDE_PATH

If specified, the include path is searched for the file and the file is written at the first location where the file already exists.

FILE_APPEND

If specified and if the file specified by path already exists, string is appended to the existing contents of the file.

LOCK_EX

Exclusively lock the file before writing to it.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required