php basename() function - how to get filename from a path in php
basenameFunction.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>php basename() function - how to get filename from a path in php</title>
</head>
<body>
<h2 style="color:Crimson; font-style:italic">php basename() function example: how to get file name</h2>
<hr width="510" align="left" color="Orange" />
<br />
<?php
// this is a file path
$filepath = "/test/testcode.php";
echo "File Path: <b>" . $filepath . "</b><br />";
// get the file name without extension.
echo "file name without extension: <b>" . basename($filepath,".php") . "</b>";
echo "<br />";
// get the file name with extension.
echo "filename with extension: <b>" . basename($filepath) . "</b>";
?>
</body>
</html>