English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The ctype_cntrl() function checks if all characters in the string are control characters.
ctype_cntrl($text);
Check if all characters in the provided string text are control characters. Control characters are for example: newline, indentation, space, tab, escape character, etc.
Serial number | Parameters and descriptions |
---|---|
1 | text(Required) The string to be tested |
If each character in the text is a control character in the current language environment, it returns TRUE; otherwise, it returns FALSE.
Determine if the string is entirely control characters:
<?php $strings = array('string1=> '\n\r\t', 'string2=> 'arf12'); foreach ($strings as $name => $testcase) { if (ctype_cntrl($testcase)) { echo "String '$name' is composed of control characters.\n"; } else { echo "String '$name' is not all control characters.\n"; } } ?>Test and see‹/›
Output result:
String 'string1is composed of control characters. String 'string2Not all are control characters.