Provides a simple example of PHP to determine the case letter function, it can find out how many uppercase letters in a string has how many lowercase letter, is a very convenient common function, the code is as follows:
function Checkcase ($STR) {
if (Preg_match ('/^[a-z]+$/', $str)) {
echo ' Small Letter ';
}elseif (Preg_match ('/^[a-z]+$/', $str)) {
echo ' capital letters ';
}
}
Method Two, the code is as follows:
<?php
$str = ' a ';
function Checkcase1 ($STR) {
$str = Ord ($STR);
if ($str >64&& $str <91) {
echo ' capital letters ';
Return
}
if ($str >96&& $str <123) {
echo ' Small Letter ';
Return
}
Echo ' is not a letter ';
}
function Checkcase2 ($STR) {
if (Strtoupper ($str) = = = $str) {
echo ' capital letters ';
}else{
echo ' Small Letter ';
}
}
echo checkcase1 ($STR);
echo Checkcase2 ($STR);
Open source software: phpfensi.com
?>