update page now
Laravel Live Japan

ReflectionClass::getStartLine

(PHP 5, PHP 7, PHP 8)

ReflectionClass::getStartLine開始行を取得する

説明

public ReflectionClass::getStartLine(): int|false

開始行を取得します。

パラメータ

この関数にはパラメータはありません。

戻り値

開始行を整数で返します。 開始行が不明な場合は、false を返します。

参考

add a note

User Contributed Notes 1 note

up
0
info at ensostudio dot ru
4 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