note 119688 deleted from splfileinfo.getbasename by salathe
| From: | salathe@php.net | Date: | Wed, 03 Aug 2016 08:06:52 +0000 |
| Subject: | note 119688 deleted from splfileinfo.getbasename by salathe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-206197@lists.php.net to get a copy of this message | ||
Note Submitter: ohcc at 163 dot com
----
It's weird thatSplFileInfo::getFilename and SplFileInfo::getBasename return the same results.
To get the filename wiout extension and the . sign if any
<?php
$fileInfo = new SplFileInfo('index.php');
echo $fileInfo->getBasename(strrchr($fileInfo->getBasename(), '.'));
?>
Or
<?php
echo pathInfo('index.php', PATHINFO_FILENAME);
?>