PHP - Function ctype_graph()


Advertisements


Syntax

ctype_graph ( $text );

Definition and Usage

This function checks if all of the characters in the provided string, text, creates visible output.

Parameters

Sr.No Parameter & Description
1

text(Required)

The tested string.

Return Value

It returns TRUE if every character in text is printable and actually creates visible output (no white space), FALSE otherwise.

Example

Try out following example −

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

This will produce the following result −

asdf\n\r\t consists of all (visibly) printable characters.
arf12 consists of all (visibly) printable characters
LKA#@%.54 consists of all (visibly) printable characters

php_function_reference.htm

Advertisements