Detect small caps title caps and capital case string

0.27K views
no comments
19 Jan 2015 11:50 pm

There no any function available in php to detect string, this technique is used when user type login name with CAPITAL CASE, CameL caSe or Title case, web developer also prevent these type cases of string for user account loginanme because they assigned unique column of username in database, I wanted to use in a project to send warning message to user if user not choose small caps name.

Code example detect small caps from string.

$not_smallcaps = 'MyUsername';
if(strtolower($not_smallcaps)===$not_smallcaps){
	//USER ENTERED SMALL CASE STRING
} else {
	//SEND WARNING USER ENTERED NOT SMALL CASE
}

Code example detect capital case.

$not_capitalcase = 'not capital case';

if($not_capitalcase===strtoupper($not_capitalcase)){
 //HERE IS CAPITAL CASE
} else {
 //HERE IS NOT CAPITAL CASE
}

NOTE:Your Email Address will be not shown and please do not add spamming comments because here is REL="NOFOLLOW" on your links and comments also moderated shown.
<code>Put html css or any language code under this tag</code>