Function
file_get_contents
Reads a whole file, letting other coroutines run while it waits.
Description#
function file_get_contents(
string $filename
): string|falseInside a coroutine, the file is read in 64 KiB chunks, waiting with phasync::readable() between
them. Outside one, it is the native file_get_contents(). Unlike the native function it takes no
other arguments, and it throws instead of returning false when the file cannot be opened.
Parameters#
- $filename string
- The file to read
Return values#
string|false
Errors / Exceptions#
| Exception | When |
|---|---|
Exception | When the file cannot be opened or a read fails |
Examples#
use function phasync\file_get_contents;
$config = file_get_contents(__DIR__ . '/config.json');See also#
file_put_contentsWrites a file, letting other coroutines run while it waits.