AI写作智能体 自主规划任务,支持联网查询和网页读取,多模态高效创作各类分析报告、商业计划、营销方案、教学内容等。 广告
# Coroutine::readFile 协程方式读取文件。 ```php function Coroutine::readFile(string $filename); ``` > 需要`2.1.2`或更高版本 参数 ---- * `$filename`文件名 返回值 ---- * 读取成功返回字符串内容,读取失败返回`false` * `readFile`方法没有尺寸限制,读取的内容会存放在内存中,因此读取超大文件时可能会占用过多内存 示例 --- ```php use Swoole\Coroutine as co; $filename = __DIR__ . "/defer_client.php"; co::create(function () use ($filename) { $r = co::readFile($filename); var_dump($r); }); ```