src/Trace.php
private static function getFileContent($file, $line)
    {
        $content = '';

        if (is_file($file)) {

            $fp = new \SplFileObject($file, 'r');
            $fp->seek($i = max($line - 10, 0)); // 转到第N行, seek方法参数从0开始计数

            $count = $line + 10;
            for (; $i <= $count; ++$i) {
                $content .= $i . ' ' . trim($fp->current()) . PHP_EOL; // current()获取当前行内容
                if ($i == $line) {

                }

                $fp->next(); // 下一行
            }

            $content = '<pre>' . htmlspecialchars($content) . '</pre>';

        }

        return $content;
    }
private static function getFileContent($file, $line)
    {
        $content = '';

        if (is_file($file)) {

            $fp = new \SplFileObject($file, 'r');
            $fp->seek($i = max($line - 10, 0)); // 转到第N行, seek方法参数从0开始计数

            $count = $line + 10;
            for (; $i <= $count; ++$i) {
                $content .= $i . ' ' . trim($fp->current()) . PHP_EOL; // current()获取当前行内容
                if ($i == $line) {

                }

                $fp->next(); // 下一行
            }

            $content = '<pre>' . htmlspecialchars($content) . '</pre>';

        }

        return $content;
    }
获取文件代码