ReflectionClass::getStartLine

(PHP 5, PHP 7, PHP 8)

ReflectionClass::getStartLine获取起始行号

说明

public ReflectionClass::getStartLine(): int|false

获取起始的行号。

参数

此函数没有参数。

返回值

起始的行号,类型是 int,如果未知,则为 false

参见

添加备注

用户贡献的备注 1 note

up
0
info at ensostudio dot ru
3 years ago
Note: lines in file start from 1!Sample to get class code:<?php$class = new ReflectionClass('Foo');$offset = $class->getStartLine() - 1;$code = implode(    '',    array_slice(        file($class->getFileName()),        $offset,        $class->getEndLine() - $offset    ));?>
To Top