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]; } ?> |