从一个标准的url中高效的取出文件的扩展名。http://www.test.com.cn/abc/de/fg.php?id=1#abc
答案
<?php $url = 'http://www.test.com.cn/abc/de/fg.php?id=1#abc'; // parse_url()解析URL,一个返回关联数组 $abc = parse_url($url); var_dump($abc); var_dump($abc['path']); // 获取下标 $p = strpos($abc['path'], '.'); var_dump($p); // 截取字段 $pp = substr($abc['path'],$p); var_dump($pp); ?>