PHP - Function ctype_print()


Advertisements


Syntax

ctype_print ( $text );

Definition and Usage

This function checks if all of the characters in the provided string, text, are printable.

Parameters

Parameter Description
text Required. The tested string.

Return Value

Returns TRUE if every character in text will actually create output (including blanks). Returns FALSE if text contains control characters or characters that do not have any output or control function at all.

Example

Try out following example −

<?php
   $strings = array('asdf\n\r\t', 'arf12', "fooo#int%@");
   
   foreach ($strings as $testcase) {
      if (ctype_print($testcase)) {
         echo "$testcase consists of all printable characters. \n";
      }
      else 
      {
         echo "$testcase does not have all printable characters. \n";
      }
   }
?> 

This will produce the following result −

asdf\n\r\t consists of all printable characters.
arf12 consists of all printable characters.
fooo#int%@ consists of all printable characters.

php_function_reference.htm