<?php //获取连接里边的id $url = 'http://www.rong123.com/cjbkscbsd/x_dfsdfs/24454_1_1.html'; function getIdByUrl($url) { $id = ''; $filename = basename($url,".html"); $id = str_replace('-', '_', $filename); if(strstr($id, '_')) { $conids = explode('_', $id); $id = $conids[0]; } return $id; } echo getIdByUrl($url).'<hr/>'; //获取完整文件名 echo basename($url).'<hr/>'; //获取没有后缀的文件名 echo basename($url,".html"); ?>