SplFileInfo::getFilename

(PHP 5 >= 5.1.2, PHP 7, PHP 8)

SplFileInfo::getFilenameLit le nom du fichier

Description

publicSplFileInfo::getFilename(): string

Lit le nom du fichier, sans chemin.

Liste de paramètres

Cette fonction ne contient aucun paramètre.

Valeurs de retour

Le nom du fichier.

Exemples

Exemple #1 Exemple avec SplFileInfo::getFilename()

<?php
$info
= new SplFileInfo('foo.txt');
var_dump($info->getFilename());

$info = new SplFileInfo('/path/to/foo.txt');
var_dump($info->getFilename());

$info = new SplFileInfo('http://www.php.net/');
var_dump($info->getFilename());

$info = new SplFileInfo('http://www.php.net/svn.php');
var_dump($info->getFilename());
?>

Résultat de l'exemple ci-dessus est similaire à :

string(7) "foo.txt" string(7) "foo.txt" string(0) "" string(11) "svn.php"

Voir aussi

To Top