PHP Velho Oeste 2024

ReflectionClass::getStartLine

(PHP 5, PHP 7, PHP 8)

ReflectionClass::getStartLineBaşlangıç satır numarasını döndürür

Açıklama

public ReflectionClass::getStartLine(): int|false

Başlangıç satır numarasını döndürür.

Bağımsız Değişkenler

Bu işlevin bağımsız değişkeni yoktur.

Dönen Değerler

Başlangıç satır numarasını bir tamsayı olarak döndürür. Bilinmiyorsa false döner.

Ayrıca Bakınız

add a note add a note

User Contributed Notes 1 note

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