PHP - Function ctype_cntrl()


Advertisements


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.

Parameters

Sr.No Parameter & Description
1

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. \n";
      }else {
         echo "$testcase does not have all all control characters. \n";
      }
   }
?> 

This will produce the following result −

\n\r\t does not have all all control characters.
test123r does not have all all control characters.

php_function_reference.htm

Advertisements