search
Homephp教程php手册php判断大小写字母函数

php判断大小写字母函数

Jun 13, 2016 am 11:18 AM
phpfunctionjudgmentCanCaseletteritExamplefind outsupplycheckofSimple

提供一款简单实例的php判断大小写字母函数哦,它可以查找出一个字符串有多少大写字母有多少小写字母哦,是一个很方便的常用函数。  

提供一款简单实例的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         echo '大写字母';
        return;
    }
    if($str>96&&$str         echo '小写字母';
        return;
    }
    echo '不是字母';
}
function checkcase2($str){
    if(strtoupper($str)===$str){
        echo '大写字母';
    }else{
        echo '小写字母';
    }
}
echo checkcase1($str);
echo checkcase2($str);
?>

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.