Create (overwrite or append) a file, put the $contents in it, and adjust permissions
This is the same as PHP’s file_put_contents()
except that it’s preferable to use this in ProcessWire because it adjusts the file permissions configured with $config->chmodFile
.
Usage
// basic usage
$int = $files->filePutContents(string $filename, $contents);
// usage with all arguments
$int = $files->filePutContents(string $filename, $contents, int $flags = 0);
Arguments
Name | Type(s) | Description |
---|---|---|
filename | string | Filename to write to |
contents | string, mixed | Contents to write to file |
flags (optional) | int | Flags to modify behavior:
|
Return value
int
bool
Number of bytes written or boolean false on fail
Exceptions
Method can throw exceptions on error:
WireException
- if given invalid $filename (since 3.0.118)
See Also
API reference based on ProcessWire core version 3.0.236