// Careful, output is different for `filename` vs `getFilename`. Inconsistent behaviour.
$path = 'test.txt';
$pathInfo = pathinfo($path);
echo '<pre>';
print_r($pathInfo);
echo '<br>';
echo '***************';
$splFileInfo = new SplFileInfo($path);
echo '<br>';
echo $splFileInfo->getBasename();
echo '<br>';
echo $splFileInfo->getFilename();