php 获取图片后缀名的方法。
<?php
//获取图片的后缀名
class Suffix{
public $str;
public function __construct($string){
$this->str = $string;
}
public function getSuffix(){
$pos = strpos($this->str,'.',1);
$suffix = substr($this->str,$pos+1);
return $suffix;
}
}
$str = new Suffix('45.17226c-jw1d.r52jjo4ppj.jpg');
echo $str->getSuffix(); //result:jpg
//by http://www.jb200.com
?>