Exception::getFile

(PHP 5, PHP 7, PHP 8)

Exception::getFileİstisnanın oluştuğu dosyanın adı ile döner

Açıklama

final public Exception::getFile(): string

İstisnanın oluştuğu dosyanın adı ile döner.

Değiştirgeler

Bu işlevin değiştirgesi yoktur.

Dönen Değerler

İstisnanın oluştuğu dosyanın adı ile döner.

Örnekler

Örnek 1 - Exception::getFile() örneği

<?php
try {
    throw new 
Exception;
} catch(
Exception $e) {
    echo 
$e->getFile();
}
?>

Yukarıdaki örnek şuna benzer bir çıktı üretir:

/home/bjori/tmp/ex.php

Ayrıca Bakınız

add a note add a note

User Contributed Notes 1 note

up
1
Jan
4 years ago
If you're looking to extract only the "ex.php" part of the full "/home/bjori/tmp/ex.php", then use:

<?php
   
echo basename($e->getFile())
?>

or better yet, esp. if your paths possibly contain non-ASCII characters:

<?php
   
echo pathinfo($e->getFile())['basename']
?>
To Top