Checking for all lower case or upper case by using ctype_lower() and ctype_upper()Checking for presence of only lower case or only upper case letters by using ctype_lower() and ctype_upper()
We can check a string to know if all characters present are in lower case letters or not. Some time we may have to ask either in lower case or upper case letter to use. By using ctype_lower() function we will check and display message to user. Syntax :
Return value will be TRUE or FALSE.
Here is the code using ctype_lower()
The output of above code will be
Presence of Blank spaceThis function checks for lower cases chars only so presence of any blank space will return as FALSE only.
Output will be
Presence of Special charactersPresence of Special characters will also return FALSE , only change the string part like this in above code.
Output will be
ctype_upper : to check Upper case lettersWe can check if all chars present in a string are upper case or not by using ctype_upper() function. This function returns TRUE or FALSE based on the string.
Here is the code
Output is here
This function will retrun FALSE if any space or special characters are present inside the string.
Underscore and DotThis will return FALSE for underscore and dot if present inside the string.
Check for at least one lower case or one upper caseWe may ask user to enter at least one Upper case letter or one lower case letter or one special character in a string variable.