Check for control character(s) with ctype_cntrl in PHP
Description
The following code shows how to check for control character(s) with ctype_cntrl.
Example
/*from w w w . j a v a 2 s . c o m*/
<?php
$strings = array('string1' => "\n\r\t", 'string2' => 'asdf12');
foreach ($strings as $name => $testcase) {
if (ctype_cntrl($testcase)) {
echo "The string '$name' consists of all control characters.\n";
} else {
echo "The string '$name' does not consist of all control characters.\n";
}
}
?>
The code above generates the following result.