PHP 6 ways to get a file extension _php tutorial

Source: Internet
Author: User
Yesterday, and a friend in the PHP Exchange group (276167802, verify: CSL, interested words can join in the discussion together) mentioned PHP6 ways to get the file extension, now take it out and share it with you:

1. How to find and intercept strings


$extension =substr (STRRCHR ($file, '. '), 1);


2, String search and interception method two


$extension =substr ($file, Strrpos ($file, '. ') +1);


3, the method of array segmentation


$extension =end (Explode ('. ', $file));


4, the use of PathInfo Direct analysis method


$info = PathInfo ($file); $extension = $info [' extension '];


5. Use the second parameter of PathInfo


$extension =pathinfo ($file, pathinfo_extension);


6. Using the Finfo_file function


$finfo = Finfo_open (fileinfo_mime_type), $extension = Finfo_file ($finfo, $file); Echo $extension; Finfo_close ($finfo);


http://www.bkjia.com/PHPjc/621640.html www.bkjia.com true http://www.bkjia.com/PHPjc/621640.html techarticle yesterday, and a friend in the PHP Exchange group (276167802, verify: CSL, interested words can join in the discussion together) mentioned in PHP to get the extension of the file 6 methods, now take out ...

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