Funkce PHP basename().
❮ Reference souborového systému PHPPříklad
Vraťte název souboru ze zadané cesty:
<?php
$path = "/testweb/home.php";
//Show filename
echo basename($path) ."<br/>";
//Show filename, but cut off file extension for ".php" files
echo basename($path,".php");
?>
Výstupem výše uvedeného kódu bude:
home.php
home
Definice a použití
Funkce basename() vrací název souboru z cesty.
Syntax
basename(path, suffix)
Hodnoty parametrů
Parameter | Description |
---|---|
path | Required. Specifies a file path |
suffix | Optional. A file extension. If the filename has this file extension, the file extension will be cut off |
Technické údaje
Návratová hodnota: | Název souboru zadané cesty |
---|---|
Verze PHP: | 4,0+ |
❮ Reference souborového systému PHP