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 is every character in $text is printable, otherwise return false.

Examples:

Input  : Geeks
Output : Yes

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

Below is the implementation of ctype_graph() function.
Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

Geeksforgeeks: Visible

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
// PHP program to check given string
// produce visible output or not
  
$string = array(
    "@!#$%^&*()_+",
    "peacefull 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";
}
  
?>

chevron_right


Output:

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

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



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



Improved By : nidhi_biet



Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.