I am trying to unlink files in a Directory which have no extensions.
I did following, but did not work:
$fileInfo = pathinfo($this->outputPath);
if($fileInfo['extension'] == NULL)
{
unlink($fileInfo['dirname'].$fileInfo['basename']);
}
As @CBroe noticed in comments:
Check for empty'ness instead:
Also, you missed a
DIRECTORY_SEPARATORbetween thedirnameand thebasename.Update: As @hassan pointed out,
emptyis not the proper way to check for this either. That's because of directories.and..on unix-like systems will pass this test, which is not desired.So, the proper way to check for files without
extensionwould be: