Tutorials Point


  Learning PHP
  Advanced PHP
  PHP Function Reference
  PHP Useful Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

PHP Function ctype_print()


previous

Advertisements

Syntax

ctype_print ( $text );

Definition and Usage

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

Paramters

ParameterDescription
textRequired. 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.<br />";
 } else {
     echo "$testcase does not have all printable characters.<br />";
 }
}
?> 

This will produce following result:

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

previous Printer Friendly

Advertisements


  

Advertisements