Computer >> Computer tutorials >  >> Programming >> PHP

ctype_graph() function in PHP


The ctype_graph() function check for any printable character(s) except space. It returns TRUE if every character in the string text is a decimal digit, FALSE otherwise.

Syntax

ctype_graph(str)

Parameters

  • str  − The tested string.

Return

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

Example

The following is an example −

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

Output

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