php custom extension get function

墨辰丷
Release: 2023-03-28 11:24:02
Original
1468 people have browsed it

This article mainly introduces the PHP custom extension acquisition function, and analyzes PHP's interception operation implementation skills for file extensions in the form of examples. Friends in need can refer to it

The details are as follows:


<?php
$url = "http://www.abc.com/abc/de/fg.php?id=1";
//这个是自己写的
function getUrl($url) {
  $date = explode(&#39;?&#39;, $url);
  $date = basename($date[0]);
  $date = explode(&#39;.&#39;, $date);
  return $date[1];
}
var_dump(getUrl($url));
//下面两个是网上弄的
function getExt($url){
  $arr = parse_url($url);
  $file = basename($arr[&#39;path&#39;]);
  $ext = explode(".",$file);
  return $ext[1];
}
var_dump(getExt($url));
function getName($url) {
  $w_param = pathinfo($url);
  $str = $w_param[&#39;extension&#39;];
  list($type, $vars) = explode(&#39;?&#39;,$str);
  return $type;
}
echo &#39;start3&#39;.date("Y-m-d H:i:s");
Copy after login



The above is the entire content of this article, I hope it will be helpful to everyone's study.


Related recommendations:

A php custom function to get the file extension

Extension functions and methods of extending custom classes in the Laravel framework, laravel framework

Extension functions and methods of extending custom classes in the Laravel framework, laravel framework_PHP tutorial


The above is the detailed content of php custom extension get function. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!