• PHP Video Tutorials

PHP - Function ctype_print()



Syntax

ctype_print ( $text );

Definition and Usage

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

Parameters

Sr.No Parameter & Description
1

text(Required)

The tested string.

Return Value

It 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', 'k211', "fooo#int%@");
   
   foreach ($strings as $test) {
      if (ctype_print($test)) {
         echo "$test consists of all printable characters. \n";
      }else {
         echo "$test does not have all printable characters. \n";
      }
   }
?> 

This will produce the following result −

asdf\n\r\t consists of all printable characters.
k211 consists of all printable characters.
fooo#int%@ consists of all printable characters.
php_function_reference.htm
Advertisements