Home > php教程 > PHP源码 > body text

PHP single character case conversion class

大家讲道理
Release: 2016-11-08 14:18:00
Original
1429 people have browsed it

<?php
/*
 *
 * @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 );
    }
}
Copy after login

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!