update page now
Laravel Live Japan

ReflectionClass::getStartLine

(PHP 5, PHP 7, PHP 8)

ReflectionClass::getStartLineGets starting line number

Beschreibung

public ReflectionClass::getStartLine(): int|false

Get the starting line number.

Parameter-Liste

Diese Funktion besitzt keine Parameter.

Rückgabewerte

The starting line number, as an int, or false if unknown.

Siehe auch

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