 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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
 