PHP gets the file suffix. There are many ways to get the file extension. The following three methods are provided to get the file suffix. You can study it and the specific code will not be explained. Check the Code directly.
PHP gets the file suffix. There are many ways to get the file extension. The following three methods are provided to get the file suffix. You can study it and the specific code will not be explained. Check the Code directly.
<? Php
// Method 1:
Function extend_1 ($ file_name)
{
$ Retval = "";
$ Pt = strrpos ($ file_name ,".");
If ($ pt) $ retval = substr ($ file_name, $ pt + 1, strlen ($ file_name)-$ pt );
Return ($ retval );
}
// 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];
}
?>
Remember, you can use it directly when you need to use it in the future, or you can click here to view this article.