Php case-sensitive letter function _ PHP Tutorial

Source: Internet
Author: User
Php case-sensitive letter function. It provides a simple php function for judging uppercase and lowercase letters of a string. it can be used to find the numbers of uppercase letters and lowercase letters of a string. It provides a simple php function for judging uppercase and lowercase letters of a string. it is a convenient and common function.

It provides a simple php example to determine the upper and lower case letters of a string. it is a convenient and common function.

Function checkcase ($ str ){
If (preg_match ('/^ [a-z] + $/', $ str )){
Echo 'lower-case letters ';
} Elseif (preg_match ('/^ [a-z] + $/', $ str )){
Echo 'uppercase letters ';
}
}

Method 2

$ Str = 'a ';
Function checkcase1 ($ str ){
$ Str = ord ($ str );
If ($ str> 64 & $ str <91 ){
Echo 'uppercase letters ';
Return;
}
If ($ str> 96 & $ str <123 ){
Echo 'lower-case letters ';
Return;
}
Echo 'not a letter ';
}
Function checkcase2 ($ str ){
If (strtoupper ($ str) ===$ str ){
Echo 'uppercase letters ';
} Else {
Echo 'lower-case letters ';
}
}
Echo checkcase1 ($ str );
Echo checkcase2 ($ str );
?>

Bytes. Mention...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.