9 ways to get file suffixes in PHP _php tips

Source: Internet
Author: User

This article for you to share the 9 kinds of PHP to obtain file suffixes for your reference, the details are as follows

<?php/** * Created by Phpstorm. * User:liuft * DATE:2016/3/7 * time:15:46///First//function get_extension ($file)//{//$file = Explode ('. ', $
file);
Return end ($file); //second//function get_extension ($file)//{//Return substr (STRRCHR ($file, '. '), 1);/////third//function Get_extension ($file) {//return PathInfo ($file) [' extension '];//}///Fourth//function get_extension ($file)//{//R
Eturn substr ($file, Strrpos ($file, '. ') + 1); 
//Fifth//function get_extension ($file)//{//$file = Preg_split ('/\./', $file);//Return End ($file);////Sixth
function Get_extension ($file) {//$file = Strrev ($file);//Return Strrev (substr ($file, 0,strpos ($file, '. ')); Seventh//function get_extension ($file)//{//Return PathInfo ($file, pathinfo_extension);//}///eighth type//FUNCTI On Get_extension ($file)//{//Preg_match_all ('/\.[
a-za-z0-9]+/', $file, $data);
return!empty ($data [0]) substr (end ($data [0]), 1): '; }//NinethKind//function get_extension ($file) {//Return Str_replace ('. ', ', ', STRRCHR ($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 to help you learn.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.