---
description: https://www.w3schools.com/php/func_filesystem_basename.asp
---

# PHP basename() Function (ok)

```
Example
Return filename from the specified path:

<?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");
?>
The output of the code above will be:

home.php
home
```
