Wednesday, August 27, 2025
HomeLanguagesPHP | ctype_graph() Function

PHP | ctype_graph() Function

A ctype_graph() Function is inbuilt function in PHP. The given string is used to check each character and display all visible character without white-space character. If it’s visible then return True otherwise False.

Syntax:

bool ctype_graph ( $text )

Parameters: The ctype_graph() function accepts a single parameter $text file which contains tested strings. 

Return Value: It return true if every character in $text is printable, otherwise return false. 

Examples:

Input  : Geeks
Input  : http//neveropen.com\n
Output : No
Explanation : "\n" is not visible in string "http//neveropen.com\n".                   

Below is the implementation of ctype_graph() function. 

Program 1: 

PHP




<?php
// PHP program to check given string
// produce visible output or not
 
$string = "Geeksforneveropen";
 
// Check strings by using ctype_graph()
// function.
if ( ctype_graph ($string) )
    echo "$string: Visible";
 else
    echo "$string: Not Visible";
 
?>


Output:

Geeksforneveropen: Visible

Program 2: 

PHP




<?php
// PHP program to check given string
// produce visible output or not
 
$string = array(
    "@!#$%^&*()_+",
    "peaceful mind",
    '45600'
);
 
// Check strings by using ctype_graph()
// function.
foreach ($string as $test) {
    if (ctype_graph($test))
        echo "$test: Visible\n";
    else
        echo "$test: Not Visible\n";
}
 
?>


Output:

@!#$%^&*()_+: Visible
peaceful mind: Not Visible
45600: Visible

Related Article: PHP | ctype_print() Function 
References :http://php.net/manual/en/function.ctype-graph.php

RELATED ARTICLES

Most Popular

Dominic
32236 POSTS0 COMMENTS
Milvus
80 POSTS0 COMMENTS
Nango Kala
6609 POSTS0 COMMENTS
Nicole Veronica
11779 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11828 POSTS0 COMMENTS
Shaida Kate Naidoo
6719 POSTS0 COMMENTS
Ted Musemwa
7002 POSTS0 COMMENTS
Thapelo Manthata
6678 POSTS0 COMMENTS
Umr Jansen
6690 POSTS0 COMMENTS