-
-
//Get file extension - $file = 'jbxue.com.php';
//Method 1
- $path_info = pathinfo($file);
- //print_r($path_info);
- //echo "
";
- //echo $path_info['dirname'];
- //echo "
";
- //echo $path_info['basename'];
- echo "
";
- echo strtolower($path_info['extension']);
//Method 2
- echo "---------------------
";
- $p = strrpos($file,'.'); //Get the last point The position of
- echo strtolower(substr($file,$p+1));
//Method 3
- echo "--------------- ------
";
- $arr = explode('.',$file);
- echo strtolower($arr[count($arr)-1]);
//Method 4
- echo "---------------------
";
- $arr = explode('.' ,$file);
- echo strtolower(end($arr));
//Method 5
- echo "----------------- ----
";
- preg_match('/.(w+)$/',$file,$extend);
- echo strtolower($extend['1']);
//Method 6
- echo "---------------------
";
- //strrchr($file,' .') from the last occurrence position to the last string
- echo strtolower(substr(strrchr($file,'.'),1));
-
- //by http://bbs.it-home.org
- ?>
-
Copy the code
Attachment: A little knowledge about extensions
A file extension is a mechanism used by the operating system to identify a file format.
Normally, an extension follows the main file name, separated by a delimiter.
In a file name like "readme.txt", readme is the main file name and txt is the extension, indicating that the file is considered a plain text file.
|