linux环境下pathinfo 工作失败的改进函数

 1 function path_info($path, $type = null) {

 2     $pathinfo = str_replace('%2F', '/', rawurlencode($path));

 3     $pathinfo = pathinfo($pathinfo);

 4     if($pathinfo){

 5         foreach($pathinfo as $key => $val){

 6            $pathinfo[$key] = rawurldecode($val);

 7         }

 8     }

 9 

10     switch ($type) {

11         case PATHINFO_DIRNAME:

12             return $pathinfo["dirname"];

13         case PATHINFO_BASENAME:

14             return $pathinfo["basename"];

15         case PATHINFO_FILENAME:

16             return $pathinfo["filename"];

17         case PATHINFO_EXTENSION:

18             return $pathinfo["extension"];

19         default :

20             return $pathinfo;

21     }

22 

23 }

 

你可能感兴趣的:(linux)