PHP | ctype_graph() Function
Last Updated :
29 Mar, 2023
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//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:
PHP
<?php
$string = "Geeksforgeeks";
if ( ctype_graph ( $string ) )
echo " $string : Visible";
else
echo " $string : Not Visible";
?>
|
Output:
Geeksforgeeks: Visible
Program 2:
PHP
<?php
$string = array (
"@!#$%^&*()_+",
"peaceful mind",
'45600'
);
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
Share your thoughts in the comments
Please Login to comment...