ReflectionClass::getStartLine
(PHP 5, PHP 7, PHP 8)
ReflectionClass::getStartLine — 获取起始行号
说明
public ReflectionClass::getStartLine(): int
获取起始的行号。
警告
本函数还未编写文档,仅有参数列表。
参数
此函数没有参数。
返回值
起始的行号,类型是 integer 的。

User Contributed Notes 1 note
info at ensostudio dot ru ¶
7 months 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
)
);
?>
备份地址:http://www.lvesu.com/blog/php/reflectionclass.getstartline.php