• PHP Video Tutorials

PHP - Function ctype_cntrl()



Syntax

ctype_cntrl ( $text );

Definition and Usage

It 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

It 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', 'example1234r');
   
   foreach ($strings as $test) {
      if (ctype_cntrl($test)) {
         echo "$test consists of all control characters. \n";
      }else {
         echo "$test does not have all all control characters. \n";
      }
   }
?> 

This will produce the following result −

\n\r\t does not have all all control characters.
example1234r does not have all all control characters.
php_function_reference.htm
Advertisements