Coroutine::getSpawnFileAndLine
(PHP 8.6+, True Async 1.0)
public Coroutine::getSpawnFileAndLine(): array
返回调用 spawn() 创建此协程时的文件和行号。
返回值
array – 包含两个元素的数组:
[0]– 文件名(string或null)[1]– 行号(int)
示例
示例 #1 基本用法
<?php
use function Async\spawn;
$coroutine = spawn(fn() => "test"); // line 5
[$file, $line] = $coroutine->getSpawnFileAndLine();
echo "File: $file\n"; // /app/script.php
echo "Line: $line\n"; // 5
参见
- Coroutine::getSpawnLocation – 以字符串形式获取创建位置
- Coroutine::getSuspendFileAndLine – 挂起时的文件和行号