php获取URL扩展名
一切拿代码来说话:
举例:'http://www.sina.com.cn/abc/de/fg.php?id=1';
$url = 'http://www.sina.com.cn/abc/de/fg.php?id=1'; $url = parse_url($url,PHP_URL_PATH); echo pathinfo($url,PATHINFO_EXTENSION).PHP_EOL; //1 $url = explode('.',$url);//2 echo end($url).PHP_EOL; echo ltrim(strrchr($url,'.'),'.').PHP_EOL; //3 echo substr(strrchr($url,'.'),1).PHP_EOL; //4 echo substr($url,strrpos($url,'.')+1).PHP_EOL; //5