How to find the extension of an image from path in PHP?

前端 未结 9 776
抹茶落季
抹茶落季 2021-01-04 12:52

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

For example ff my image path is like \'/testdir/dir2/image

9条回答
  •  [愿得一人]
    2021-01-04 13:31

    It's usually more desirable to detect the actual image type (not by extension but by its contents). For that, use getimagesize().

提交回复
热议问题