ReflectionClass::getStartLine
(PHP 5, PHP 7, PHP 8)
ReflectionClass::getStartLine — 获取起始行号
参数
此函数没有参数。
+添加备注
用户贡献的备注 1 note
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
)
);
?>
备份地址:http://www.lvesu.com/blog/php/reflectionclass.getstartline.php