Home >Backend Development >PHP Tutorial >9 ways to get file suffix in php, _PHP tutorial

9 ways to get file suffix in php, _PHP tutorial

WBOY
WBOYOriginal
2016-07-12 08:56:10929browse

9 ways to get file suffix in php,

The examples in this article share 9 ways to get file suffix in php for your reference, the specific content is as follows

<&#63;php
/**
 * Created by PhpStorm.
 * User: liuft
 * Date: 2016/3/7
 * Time: 15:46
 */
 
//第一种
// function get_extension($file)
// {
// $file = explode('.', $file);
//   return end($file);
// }
//第二种
 
// function get_extension($file)
// {
//   return substr(strrchr($file, '.'), 1);
// }
 
 
//第三种
// function get_extension($file){
// return pathinfo($file)['extension'];
// }
// 
 
 
//第四种
//function get_extension($file)
//{
//  return substr($file, strrpos($file, '.') + 1);
//}
 
//第五种
//function get_extension($file)
//{
// $file = preg_split('/\./', $file);
//  return end($file);
//}
 
 
//第六种
// function  get_extension($file){
// $file = strrev($file);
//   return strrev(substr($file,0,strpos($file,'.')));
// }
//
 
//第七种
// function get_extension($file)
// {
//   return pathinfo($file, PATHINFO_EXTENSION);
// }
// 
//第八种
// function get_extension($file)
// {
//   preg_match_all('/\.[a-zA-Z0-9]+/',$file,$data);
//   return !empty($data[0])&#63;substr(end($data[0]),1):'';
// }
 
 
//第九种
// function get_extension($file){
//   return str_replace('.','',strrchr($file,'.'));
// }
 
 
//暂时想这么多,以后想起来再补充
 
$file = "http://10.31.63.8:8081/M00/00/09/Ch8_CFaaMLqAO87JAACePvS0ZRk.webp";
 
$data = get_extension($file);
 
var_export($data);

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

Articles you may be interested in:

  • php code to change the suffix of all files in a directory and subdirectories
  • php to change the suffix extension of all files in a directory and subdirectories Name code
  • Function code for batch modifying file suffix names in PHP
  • Three functions for PHP to obtain file suffix names
  • How to modify the specified file suffix in PHP
  • Analysis of examples of obtaining file suffix names with one line of php code
  • PHP method to implement batch modification of file suffix names
  • PHP implements several common methods to obtain file suffix names

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1113715.htmlTechArticle9 ways to get the file suffix in PHP. This example shares 9 ways to get the file suffix in PHP. For your reference, the specific content is as follows php/** * Created by PhpStorm. * User:...
Statement:
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