|
|
Return filename component of path - PHP
|
Views : 336
|
|
Tagged in : PHP
|
|
|
Report This Scrap as Inappropriate We request you to choose the appropriate categroy and subcategory that suits your
objectionable concern about the scrap, So that our team can review and find out whether it violates our Guidelines or the
scrap is not suitable for all viewers.
|
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 |
|
|
|