Home >Backend Development >PHP Tutorial >How to get file extension in php? Three ways to get file extension in php

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-25 08:51:221252browse
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]; } ?>



Statement:
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