Hi,
I created a function that returns the extension of a file:
public static function getFileExtension($fileName
) {
$pathInfo = pathinfo($fileName);
return $pathInfo['extension'];
}
But when the file has no extension, I get the Notice: Undefined index: extension
I do not want such an error and rather return an empty string in the function.
Thank you.
Start Free Trial