The file_put_contents() writes a string to a file.
This function follows these rules when accessing a file:
This function returns the number of character written into the file on success, or FALSE on failure.
|file||Required. Specifies the file to write to. If the file does not exist, this function will create one|
|data||Required. The data to write to the file. Can be a string, an array or a data stream|
|mode||Optional. Specifies how to open/write to the file. Possible
|context||Optional. Specifies the context of the file handle. Context is a set of options that can modify the behavior of a stream.|
Note: Use FILE_APPEND to avoid deleting the existing content of the file.
The output of the code above will be:
Your message has been sent to W3Schools.