How do I get a file extension in PHP?

前端 未结 28 2260
一向
一向 2020-11-21 22:45

This is a question you can read everywhere on the web with various answers:

$ext = end(explode(\'.\', $filename));
$ext = substr(strrchr($filename, \'.\'), 1         


        
28条回答
  •  孤独总比滥情好
    2020-11-21 23:10

    Use substr($path, strrpos($path,'.')+1);. It is the fastest method of all compares.

    @Kurt Zhong already answered.

    Let's check the comparative result here: https://eval.in/661574

提交回复
热议问题