Learning PHP
Advanced PHP
PHP Function Reference
PHP Useful Resources
Selected Reading
© 2011 TutorialsPoint.COM
|
PHP Function ctype_cntrl()
Syntax
Definition and Usage
Checks if all of the characters in the provided string, text, are control characters. Control characters are e.g. line feed, tab, escape.
Paramters
Parameter | Description |
text | Required. The tested string. |
Return Value
Returns TRUE if every character in text is a control character from the current locale, FALSE otherwise.
Example
Try out following example:
<?php
$strings = array('\n\r\t', 'test123r');
foreach ($strings as $testcase) {
if (ctype_cntrl($testcase)) {
echo "$testcase consists of all control characters.<br />";
} else {
echo "$testcase does not have all all control characters.<br />";
}
}
?>
|
This will produce following result:
\n\r\t consists of all control characters.
test123r does not have all all control characters.
|
|
|
|