PHP获取文件扩展名

1.

substr(strrchr("http://www.xxx.com/public/abc.jpg", .), 1);

string strrchr(string,needle) 获取字符串中出现指定字符串的最后位置到末尾的内容
int strrpos(string,needle) 获取字符串中出现指定字符串的最后位置
string substr(string,position) 从指定位置截取字符串到末尾
string strchr(string,needle) 获取字符串中出现指定字符串的最先位置到末尾的内容
int strpos(string,needle) 获取字符串中出现指定字符串的最先位置

2.

substr($path, strrpos($path, .) + 1)

3.

array_pop(explode(., $path))

4.

(pathinfo($path))[extension]

  pathinfo($path) 返回: 

dirname => string http://www.baidu.com/public (length=27)

basename => string abc.jpg (length=7)

extension => string jpg (length=3)

filename => string abc (length=3)