swoole 异步系统文件IO
生活随笔
收集整理的這篇文章主要介紹了
swoole 异步系统文件IO
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
https://wiki.swoole.com/wiki/page/183.html
一.讀文件
//函數(shù)寫法 //$result = swoole_async_readfile(__DIR__ . '/test.html', function ($filename, $fileContent) { //命名空間寫法 $result = Swoole\Async::readFile(__DIR__ . '/test.html', function ($filename, $fileContent) { echo 'filename:' . $filename . PHP_EOL; echo 'content:' . $fileContent . PHP_EOL; }); print_r($result); echo 'start' . PHP_EOL;以上輸出順序
1.print_r($result);
2. echo 'start';
3.filename
4.content
二.寫文件
/** * 寫入文件 * __DIR__ * FILE_APPEND以追加的方式寫入 * 最在不可超過(guò)4M,超過(guò)4M用swoole_async_write */ $content = '這是我要寫入的信息'. PHP_EOL; $result = swoole_async_writefile(__DIR__ . '/test.html', $content, function ($filename) { echo 'write succ filename:' . $filename . PHP_EOL; }, FILE_APPEND); print_r($result); echo 'start' . PHP_EOL;總結(jié)
以上是生活随笔為你收集整理的swoole 异步系统文件IO的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: swoole 定时器
- 下一篇: swoole 异步MYSQL