News新闻

业界新闻动态、技术前沿
Who are we?

您的位置:首页      乐道系统FAQ      php自定义扩展名获取函数示例

php自定义扩展名获取函数示例

发布日期:2016-12-12 00:00:00 85

本文实例讲述了php自定义扩展名获取函数。分享给大家供大家参考,具体如下:

<?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");