ReflectionClass::getFileName

(PHP 5, PHP 7, PHP 8)

ReflectionClass::getFileNameクラスが定義されているファイルのファイル名を取得する

説明

public ReflectionClass::getFileName(): string|false

クラスが定義されているファイルのファイル名を取得します。

パラメータ

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

戻り値

クラスが定義されているファイルのファイル名を返します。 そのクラスが PHP のコアあるいは PHP の拡張モジュール内で定義されている場合は false を返します。

参考

add a note

User Contributed Notes 2 notes

up
2
robot at znframework dot com
7 years ago
<?php

$a
= new \ReflectionClass('ZN\Database\InternalDB');

var_dump($a->getFileName());

// Output: C:\xampp7\htdocs\develop\Internal\Database\DB\InternalDB.php
up
1
me at yeganemehr dot net
10 months ago
Please note that returned value from this function is actually realpath of the file and if your file is symlink, target of the link will return.
To Top