本文实例讲述了php自定义扩展名获取函数。分享给大家供大家参考,具体如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
<?php $url = "http://www.abc.com/abc/de/fg.php?id=1" ; //这个是自己写的 function getUrl( $url ) { $date = explode ( '?' , $url ); $date = basename ( $date [0]); $date = explode ( '.' , $date ); return $date [1]; } var_dump(getUrl( $url )); //下面两个是网上弄的 function getExt( $url ){ $arr = parse_url ( $url ); $file = basename ( $arr [ 'path' ]); $ext = explode ( "." , $file ); return $ext [1]; } var_dump(getExt( $url )); function getName( $url ) { $w_param = pathinfo ( $url ); $str = $w_param [ 'extension' ]; list( $type , $vars ) = explode ( '?' , $str ); return $type ; } echo 'start3' . date ( "Y-m-d H:i:s" ); |
希望本文所述对大家PHP程序设计有所帮助。