Two ways to get the file name extension in PHP

Source: Internet
Author: User
This article describes, The PHP code used to get the file name extension, which gets the extension in PHP, is convenient to use the PathInfo () method. Refer to a friend who needs it.

In PHP, it is easy to get the file extension from the end of the file. With PHP function PathInfo, you can do this by paying attention to the number of points in front of the file extension in use. The extension that is obtained by using pathinfo () is not included in the dot number.

The following are two ways to get file name extensions, as follows.

Method 1,

 

Method Two, which is basically the same as method one, but uses a string operation to get the extension, using the. Number as the delimiter.

Code:

  • Related Article

    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.