Swoole\Coroutine\System::writeFile(string $filename, string $content, int $flags)

Declaration

<?php
Swoole\Coroutine\System::writeFile(string $filename, string $content, int $flags)

Parameters

filename

the location of a file.

content

the content to be written to the file.

flags

FILE_APPEND

Return

cid

Coroutine ID.

Description

Alias: Swoole\Coroutine::writeFile.

Write content into a file.

Maximum size of $fileContent is 4MB.

$flags should be FILE_APPEND if appending to the file.

Example

<?php

Co\run(function() {
    $filename = __DIR__ . "/test.txt";
    $r = co\System::writeFile($filename, "hello\n");
    var_dump($r);
});