提供以上两种方式读取:

<?php
//异步读取文件
swoole_async_readfile(__DIR__."/1.txt",function($filename,$content){
    echo "$filename $content";
});

 

php-swoole异步写入读取

写入方式:

<?php
//异步写入文件
$content = "nihao ,woshi,nidandong";
swoole_async_writefile('2.txt',$content,function($filename){
    echo $filename;
},0);

相关文章: