PHP Conference Nagoya 2025

ReflectionClass::getFileName

(PHP 5, PHP 7, PHP 8)

ReflectionClass::getFileNameGets the filename of the file in which the class has been defined

Description

public ReflectionClass::getFileName(): string|false

Gets the filename of the file in which the class has been defined.

Parameters

This function has no parameters.

Return Values

Returns the filename of the file in which the class has been defined. If the class is defined in the PHP core or in a PHP extension, false is returned.

See Also

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
0
me at yeganemehr dot net
4 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