【www.gdgbn.com--php函数】

 代码如下   function checkcase($str){
              if(preg_match("/^[a-z]+$/", $str)){
                     echo "小写字母";
              }elseif(preg_match("/^[a-z]+$/", $str)){
                     echo "大写字母";
              }
       }

方法二

 代码如下 $str = "a";
function checkcase1($str){
    $str = ord($str);
    if($str>64&&$str<91){
        echo "大写字母";
        return;
    }
    if($str>96&&$str<123){
        echo "小写字母";
        return;
    }
    echo "不是字母";
}
function checkcase2($str){
    if(strtoupper($str)===$str){
        echo "大写字母";
    }else{
        echo "小写字母";
    }
}
echo checkcase1($str);
echo checkcase2($str);
?>

本文来源:http://www.gdgbn.com/jiaocheng/26647/