PHP. In php, sometimes we want to get the extension of the uploaded file. next I will summarize the method of getting the extension in php. if you need it, please refer to it. Method 1: One of my best ideas is that sometimes we want to get the extension of the uploaded file in php. below I will summarize the methods for obtaining the extension in php, for more information, see.
Method 1: One of my most convenient methods to get an extension
| The code is as follows: |
|
Function extend_2 ($ file_name) { $ Extend = pathinfo ($ file_name ); $ Extend = strtolower ($ extend ["extension"]); Return $ extend; } |
Method 2: use the combination of explode and end functions
| The code is as follows: |
|
Function get_extension ($ file) { Return end (explode ('.', $ file )); } |
Method 3 is the same as getting an extension in asp.
| The code is as follows: |
|
Function get_extension ($ file) { Substr (strrchr ($ file, '.'), 1 ); } |
Okay, there are three methods. basically, you can get the file extension.
Bytes. Method 1: One of my best ideas...