The ctype_cntrl() function check for control character(s). It returns TRUE if every character in text is a control character from the current locale, FALSE otherwise.
Syntax
ctype_cntrl(str)
Parameters
str − The tested string
Return
The ctype_cntrl() function returns TRUE if every character in text is a control character from the current locale, FALSE otherwise.
Example
The following is an example −
<?php
$arr = array('str1' =>"\n\r\t", 'str2' =>"demo76876test");
foreach ($arr as $a => $demo) {
if (ctype_cntrl($demo)) {
echo "$a has all control characters. \n";
}else {
echo "$a does not have all control characters. \n";
}
}
?>Output
str1 has all control characters. str2 does not have all control characters.