PHP How to get the file extension, _php tutorial

Source: Internet
Author: User

How PHP obtains the file extension,


There are many similar methods on the Internet, but there are such non-rigorous problems, this article does not analyze each, here only the most correct use of PHP to get the file extension (file suffix name) method.

function Get_extension ($filename) {   

The function is used in PHP built-in function pathinfo This function, the following analysis of the meaning and usage of this function:
Definition and usage
The PathInfo () function returns information about the file path in the form of an array.
Grammar
PathInfo (path,options)

Description: PathInfo () returns an associative array containing the path information. array elements include the following values:
[DirName]
[BaseName]
[Extension]

For example:

The above will output the following results :

Array ([dirname] =/testweb [basename] = test.txt [extension] = txt)

The above is for everyone to share the correct use of PHP to get the file extension (file suffix name) method, I hope you like, and apply it.

http://www.bkjia.com/PHPjc/1065569.html www.bkjia.com true http://www.bkjia.com/PHPjc/1065569.html techarticle PHP How to get the extension of the file, there are many similar methods on the Internet, but there are such a serious problem, this article will not be analyzed, here only the most correct benefit ...

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