PHP单个字符大小写转换类
时间:2021-07-01 10:21:17
帮助过:11人阅读
基本操作
- /*
- *
- * @class Base_Char
- * @author zhangys
- * @date 2012/06/25
- */
- class Base_Var_Char
- {
- public static function isUpper ( $char )
- {
- $ascii = ord ( $char );
- if( $ascii > 64 and $ascii < 91 ) return true;
- return false;
- }
- public static function isLower ( $char )
- {
- $ascii = ord ( $char );
- if( $ascii > 96 and $ascii < 123 ) return true;
- return false;
- }
- public static function toUpper ( $char )
- {
- if ( self::isUpper ( $char ) ) return $char;
- $ascii = ord ( $char );
- return chr ( $ascii - 32 );
- }
- public static function toLower ( $char )
- {
- if ( self::isLower ( $char ) ) return $char;
- $ascii = ord ( $char );
- return chr ( $ascii + 32 );
- }
- }
|