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

ParameterDescription
textRequired. The tested string.

Return Value

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 $testcase) {
 if (ctype_graph($testcase)) {
     echo "$testcase consists of all 
                        (visibly) printable characters \n";
 } else {
     echo "$testcase does not have all 
                        (visibly) printable characters. \n";
 }
}
?> 

This will produce following result:

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

php_function_reference.htm