English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
PHP Filesystem Référence Manuel
La fonction basename() peut retourner la partie du nom de fichier dans le chemin.
string basename ( string path [, string suffix])
Il fournit une chaîne contenant le chemin d'accès aux fichiers et cette fonction retourne le nom de base du fichier. Si le nom de fichier se termine par un suffixe, il peut également être tronqué.
<?php $path = \/PhpProject/"index.php"; $file = basename($path); // $file est réglé sur "index.php" echo $file . "\n"; $file = basename($path, ".php"); // $file est réglé sur "index" echo $file; ?>
Résultat de la sortie
index.php index