diff --git a/reference/filesystem/functions/file-put-contents.xml b/reference/filesystem/functions/file-put-contents.xml index b39a9cf825..ae56b58479 100644 --- a/reference/filesystem/functions/file-put-contents.xml +++ b/reference/filesystem/functions/file-put-contents.xml @@ -1,5 +1,5 @@ - + file_put_contents @@ -16,13 +16,9 @@ resourcecontext - Identical to calling fopen, fwrite, - and fclose successively. - - - You can also specify the data parameter as an array - (not multi-dimension arrays). This is equivalent to - file_put_contents($filename, implode('', $array)). + This function is identical to calling fopen, + fwrite and fclose successively + to write data to a file. @@ -34,7 +30,7 @@ filename - The file name where to write the data + Path to the file where to write the data. @@ -50,22 +46,87 @@ remaining buffer of that stream will be copied to the specified file. This is similar with using stream_copy_to_stream. + + You can also specify the data parameter as a single + dimension array. This is equivalent to + file_put_contents($filename, implode('', $array)). + flags - flags can take - FILE_USE_INCLUDE_PATH, - FILE_APPEND and/or LOCK_EX - (acquire an exclusive lock), however the - FILE_USE_INCLUDE_PATH option should be used with - caution. As of PHP 6, it can also take one of - FILE_TEXT or FILE_BINARY to - specify how newlines should be handled when outputting the file. See - fopen's "t" and "b" - modes for more information. + The value of flags can be any combination of + the following flags (with some restrictions), joined with the binary OR + (|) operator. + + + + Available flags + + + + Flag + Description + + + + + + FILE_USE_INCLUDE_PATH + + + Search for filename in the include directory. + See include_path for more + information. + + + + + FILE_APPEND + + + If file filename already exists, append + the data to the file instead of overwriting it. + + + + + LOCK_EX + + + Acquire an exclusive lock on the file while proceeding to the + writing. + + + + + FILE_TEXT + + + data will be written in UTF-8 encoding by + default. You can specify a different encoding by creating a + custom context. This flags cannot be used with + FILE_BINARY. If data + is UTF-8 and the FILE_TEXT flag is not set, + a warning will be issued. This flag is only available since PHP 6. + + + + + FILE_BINARY + + + data will be written in binary mode. This + is the default setting and cannot be used with + FILE_BINARY. This flag is only available since + PHP 6. + + + + +
@@ -117,8 +178,8 @@ 6.0.0 - Added support for FILE_TEXT and - FILE_BINARY + Added support for the FILE_TEXT and + FILE_BINARY flags