Function __global->cms_file_get_contents_safe
Definitions
sources/global3.php
- Get the contents of a file, with locking support.
- Visibility: public
- Is abstract?: No
- Is static?: No
- Is final?: No
Parameters
| Name | Type | Passed by reference? | Variadic? | Default | Set | Range | Description |
|---|---|---|---|---|---|---|---|
| $path | PATH | No | No | required parameter | N/A | N/A | File path |
| $flags | integer | No | No | 0 | N/A | N/A | FILE_READ_* flags |
| $default_charset | ?string | No | No | Null | N/A | N/A | The default character set to assume if none is specified in the file (null: website character set) |
| $max_bytes | ?integer | No | No | Null | N/A | N/A | Maximum number of bytes to read (null: read all bytes) |
Returns
- File contents (false: error)
- Type: ~string
- Set: N/A
- Range: N/A
Preview
Code (PHP)
/**
* Get the contents of a file, with locking support.
*
* @param PATH $path File path
* @param integer $flags FILE_READ_* flags
* @param ?string $default_charset The default character set to assume if none is specified in the file (null: website character set)
* @param ?integer $max_bytes Maximum number of bytes to read (null: read all bytes)
* @return ~string File contents (false: error)
*/
function cms_file_get_contents_safe(string $path, int $flags = 0, ?string $default_charset = null, ?int $max_bytes = null)
* Get the contents of a file, with locking support.
*
* @param PATH $path File path
* @param integer $flags FILE_READ_* flags
* @param ?string $default_charset The default character set to assume if none is specified in the file (null: website character set)
* @param ?integer $max_bytes Maximum number of bytes to read (null: read all bytes)
* @return ~string File contents (false: error)
*/
function cms_file_get_contents_safe(string $path, int $flags = 0, ?string $default_charset = null, ?int $max_bytes = null)
