Friday, 6 September 2013

Which function is better suited to retrieve the basename of a file in PHP: basename or pathinfo?

Which function is better suited to retrieve the basename of a file in PHP:
basename or pathinfo?

What's the recommended way of grabbing the basename (file name without
extension) of a file in PHP?
basename('foo.jpg')
or
pathinfo('foo.jpg', PATHINFO_BASENAME)
Apparently both produce the same output. I wonder if any of these covers
any additional corner cases than the other.

No comments:

Post a Comment