Home >Backend Development >PHP Tutorial >PHP determines uppercase and lowercase letters function

PHP determines uppercase and lowercase letters function

高洛峰
高洛峰Original
2016-11-29 14:50:113365browse

Provide a simple example of PHP function to determine uppercase and lowercase letters. It can find out how many uppercase letters and lowercase letters a string has. It is a very convenient and commonly used function. The code is as follows:

function checkcase($str){ _ If (preg_match ('/^[a-z]+$/', $ str)) {

echo 'lowercase letter'; ; ;

function checkcase1($str){

$str = ord($str);

if($str>64&&$str<91 ){

echo 'capital letters';

return;

}

If($str>96&&$str< )

if(strtoupper($str)=== $str){

                                                                                                    echo 'uppercase letters';                                                                                                                                                                     worse worse worse — not more less than uppercase letters";

echo checkcase2($str);

//Open source software: phpfensi.com

?>

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