Do it faster!
In other words, if you only work with a filename, please stop using pathinfo.
I mean, sure if you have a full pathname, pathinfo makes sense because it's smarter than just finding dots: the path can contain dots and filename itself may have none. So in this case, considering an input string like d:/some.thing/myfile, pathinfo and other fully equipped methods are a good choice.
But if all you have is a filename, with no path, it's simply pointless to make the system work a lot more than it needs to. And this can give you a 10x speed boost.
Here's a quick speed test:
/* 387 ns */ function method1($s) {return preg_replace("/.*\./","",$s);} // edge case problem
/* 769 ns */ function method2($s) {preg_match("/\.([^\.]+)$/",$s,$a);return $a[1];}
/* 67 ns */ function method3($s) {$n = strrpos($s,"."); if($n===false) return "";return substr($s,$n+1);}
/* 175 ns */ function method4($s) {$a = explode(".",$s);$n = count($a); if($n==1) return "";return $a[$n-1];}
/* 731 ns */ function method5($s) {return pathinfo($s, PATHINFO_EXTENSION);}
/* 732 ns */ function method6($s) {return (new SplFileInfo($s))->getExtension();}
// All measured on Linux; it will be vastly different on Windows
Those nanosecond values will obviously differ on each system, but they give a clear picture about proportions. SplFileInfo and pathinfo are great fellas, but for this kind of job it's simply not worth it to wake them up. For the same reason, explode() is considerably faster than regex. Very simple tools tend to beat more sophisticated ones.
Conclusion
This seems to be the Way of the Samurai:
function fileExtension($name) {
$n = strrpos($name, '.');
return ($n === false) ? '' : substr($name, $n+1);
}
Remember this is for simple filenames only. If you have paths involved, stick to pathinfo or deal with the dirname separately.