如何在PHP中找到路径中图像的扩展名? [英] How to find the extension of an image from path in PHP?

查看:120
本文介绍了如何在PHP中找到路径中图像的扩展名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PHP中是否有任何标准函数只能从相应的文件路径中找到图像的扩展名?

Is there any standard function in PHP to find only extension of an image from the corresponding file path?

例如,我的图像路径就像'/ testdir / dir2 / image.gif'那么函数应该返回'gif'。

For example ff my image path is like '/testdir/dir2/image.gif' then the function should return 'gif'.

谢谢

推荐答案

$ext = pathinfo('/testdir/dir2/image.gif', PATHINFO_EXTENSION); //$ext will be gif

更新:我看到很多downvotes。我的方法有什么问题?请告诉我。

UPDATE: I see a lot of downvotes. What's the problem with my approach? Please let me know.

这篇关于如何在PHP中找到路径中图像的扩展名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆