diff --git a/CHANGELOG b/CHANGELOG index bb6f0a211..d517659cc 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -21,6 +21,7 @@ Version 1.1.2 to be released - Enh: CCaptchaAction now supports unlimited tests by setting its testLimit to be 0 (Qiang) - Enh: Added $forceCopy parameter to CAssetManager::publish() (Qiang) - Enh: CTypeValidator now supports checking array data (Qiang) +- Enh: Added CFileHelper::getExtension (Qiang) - New #1005: added CWinCache (Sam Dark) Version 1.1.1 March 14, 2010 diff --git a/framework/utils/CFileHelper.php b/framework/utils/CFileHelper.php index 60e9708ac..305edc9f4 100644 --- a/framework/utils/CFileHelper.php +++ b/framework/utils/CFileHelper.php @@ -18,6 +18,21 @@ */ class CFileHelper { + /** + * Returns the extension name of a file path. + * For example, the path "path/to/something.php" would return "php". + * @param string the file path + * @return string the extension name without the dot character. + * @since 1.1.2 + */ + public static function getExtension($path) + { + if(($pos=strrpos($path,'.'))!==false) + return substr($path,$pos+1); + else + return ''; + } + /** * Copies a directory recursively as another. * If the destination directory does not exist, it will be created.