file_put_contents(file,data,mode,context)
The function writes a string to a file. Same as calling fopen(), fwrite() and fclose() in sequence.
This function will return the number of bytes of data written to the file.
parameter | describe |
---|---|
file | Required. Specifies the file to which data is to be written. If the file does not exist, create a new file. |
data | Optional. Specifies the data to be written to the file. Can be a string, an array, or a stream of data. |
mode | Optional. Specifies how to open/write the file. Possible values:
|
context | Optional. Specifies the environment for the file handle. context is a set of options that can modify the behavior of the stream. Ignored if null is used. |
file_get_contents(path,include_path,context,start,max_length)
Read the entire file into a string.
path | Required. Specifies the file to read. |
include_path | Optional. If you also want to search for files in include_path, you can set this parameter to "1". |
context | Optional. Specifies the environment for the file handle. context is a set of options that can modify the behavior of the stream. Ignored if null is used. |
start | Optional. Specifies where in the file to start reading. This parameter is new in PHP 5.1. |
max_length | Optional. Specifies the number of bytes to read. This parameter is new in PHP 5.1. |