Return filename component of path - PHP Views : 336
Tagged in : PHP
0 0
Send mail
Return filename component of path

The function basename() will return the base name of the file.

$path = "/home/hiox/html/index.php";
$file = basename($path); // $file is set to "index.php"
echo "$file";
?>


The above code will display the base name with the extension.

Result :
index.php


$path = "/home/hiox/html/index.php";
$file = basename($path, ".php"); // $file is set to "index"
echo "$file";
?>


The above code will display only the base name without extension.

Result :
index




By Sanju, On - 2010-01-03



    Login to add Comments .