How to get file extension in php? Three ways to get file extension in php

WBOY
Release: 2016-07-25 08:51:22
Original
1148 people have browsed it
How to get the file extension in php, what are the techniques for getting the file extension in php, and learn several methods of getting the file extension in php through examples. The examples are relatively simple and suitable as a reference for introductory tutorials on php.

How to get the file extension in php? What are the methods?

1. Example of simply obtaining the file extension in PHP:

Copy code Code example:

2. Three ways to get file extension in php

Example:

Copy code Code example:

//Method 2 function extend_2($file_name) { $extend = pathinfo($file_name); $extend = strtolower($extend["extension"]); return $extend; }

//Method 3 function extend_3($file_name) { $extend =explode("." , $file_name); $va=count($extend)-1; return $extend[$va]; } ?>



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!