Monday 26 August 2013

PHP Function ctype_cntrl()

Syntax

ctype_cntrl ( $text );

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

ParameterDescription
textRequired. 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.

No comments:

Post a Comment