: This article mainly introduces PHP to get the file suffix. For more information about PHP tutorials, see. PHP obtains the file suffix
Function fileSuffix ($ filename ){
Return strtolower (trim (substr (strrchr ($ filename, '.'), 1 )));
}
?>
Strrchr --- PHP function, which is used to locate the last occurrence position of a string in another string and returns all characters from this position to the end of the string. if it fails, false is returned.
Substr --- PHP function, returns a part of the string.
Trim --- PHP function to remove spaces or other predefined characters on both sides of the string.
Strtolower --- PHP function, converts a string to lowercase.
(2)
Function get_extension ($ file)
{
Return end (explode ('.', $ file ));
}
The above introduces the PHP file suffix, including the content, hope to be helpful to friends interested in PHP tutorials.