Get file extension program code in PHP _php tutorial

Source: Internet
Author: User
In PHP sometimes we want to get the extension of the upload file, below I summarize the extension in PHP to get a summary of the method, there is a need for friends to refer to.

Method One, my own most kind of get extension method

The code is as follows Copy Code

function Extend_2 ($file _name)
{
$extend = PathInfo ($file _name);
$extend = Strtolower ($extend ["extension"]);
return $extend;
}

Method Two, combining operations with the End function using the EXPLODE function

The code is as follows Copy Code

function Get_extension ($file)
{
Return End (Explode ('. ', $file));
}


Method Three, is the same as before the extension in the ASP to get the same practice.

The code is as follows Copy Code

function Get_extension ($file)
{
substr (STRRCHR ($file, '. '), 1);
}


Okay, here are the three kinds of methods, basically to meet you get the file name extension.

http://www.bkjia.com/PHPjc/628928.html www.bkjia.com true http://www.bkjia.com/PHPjc/628928.html techarticle in PHP Sometimes we want to get the extension of the upload file, below I summarize the extension in PHP to get a summary of the method, there is a need for friends to refer to. Method One, my own one of the most won ...

  • 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.