Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
How to get file name from a path in PHP?
To get the file name from a path, the code is as follows−
Example
<?php
$file = pathinfo('/home/cg/root/6985034/main.php');
echo $file['basename'], "
";
?>
Output
This will produce the following output−
main.php
Example
Let us now see another example −
<?php $path = "/home/cg/root/6985034/main.php"; $file = basename($path, ".php"); echo $file; ?>
Output
This will produce the following output−
main
Advertisements
