Menu
Reference
- Manticore\Ds
- Async
- Classes
- AggregateError
- CancellationToken
- CancelledException
- Channel
- ChannelClosedException
- Context
- DeadlockException
- Mutex
- Once
- Pool
- Received
- SelectCase
- Selected
- Semaphore
- Settled
- Task
- TaskGroup
- TimeoutException
- Functions
- async()
- awaitAll()
- awaitAllSettled()
- awaitAny()
- channel()
- delay()
- dump()
- dumpOn()
- failure()
- group()
- mapConcurrent()
- mapSettled()
- readFile()
- select()
- selectNow()
- selectWithin()
- shield()
- shutdownOn()
- spawn()
- stats()
- timeout()
- watchdog()
- writeFile()
- Http
- Http\WebSocket
- Buffer
- Process
- Io\Poll
- Manticore\Sapi
- Ffi
writeFile()
function
function writeFile(string $path, string $data, int $chunk = 1048576): int
Write $data to a file in chunks, yielding to other tasks between them.
The same contract as readFile(). The file is created or truncated.
Parameters
$pathstring- the file to write
$datastring- the contents
$chunkint = 1048576- bytes per write; default 1 MiB
Returns
int — the number of bytes written, or -1 when the file cannot be opened
Throws
- CancelledException
- when the task is cancelled between chunks
See also: readFile