Function __global->cms_file_put_contents_safe
Definitions
sources/files.php
- Write out to a file, with lots of error checking and locking.
- Visibility: public
- Is abstract?: No
- Is static?: No
- Is final?: No
- Returns: bool
Parameters
| Name | Type | Passed by reference? | Variadic? | Default | Set | Range | Description |
|---|---|---|---|---|---|---|---|
| $path | PATH | No | No | required parameter | N/A | N/A | File path |
| $contents | string | No | No | required parameter | N/A | N/A | File contents |
| $flags | integer | No | No | 4 | N/A | N/A | FILE_WRITE_* flags |
| $charset | ?string | No | No | Null | N/A | N/A | Character set to write with (null: website character set) |
| $retry_depth | integer | No | No | 0 | N/A | N/A | How deep it is into retrying if somehow the data did not get written |
Returns
- Success status
- Type: boolean
- Set: N/A
- Range: N/A
Preview
Code (PHP)
/**
* Write out to a file, with lots of error checking and locking.
*
* @param PATH $path File path
* @param string $contents File contents
* @param integer $flags FILE_WRITE_* flags
* @param ?string $charset Character set to write with (null: website character set)
* @param integer $retry_depth How deep it is into retrying if somehow the data did not get written
* @return boolean Success status
*/
function cms_file_put_contents_safe(string $path, string $contents, int $flags = 4, ?string $charset = null, int $retry_depth = 0) : bool
* Write out to a file, with lots of error checking and locking.
*
* @param PATH $path File path
* @param string $contents File contents
* @param integer $flags FILE_WRITE_* flags
* @param ?string $charset Character set to write with (null: website character set)
* @param integer $retry_depth How deep it is into retrying if somehow the data did not get written
* @return boolean Success status
*/
function cms_file_put_contents_safe(string $path, string $contents, int $flags = 4, ?string $charset = null, int $retry_depth = 0) : bool

