PHP Ctype_punct () Function

PHP

Syntax:
bool ctype_punct ($text)
Parameters:this function takes one parameter $text. This is a required parameter and specifies the string.Return Value:Returns True if the string contains no alphanumeric, numeric, or blank characters, and False on error. 
Examples:
Input: GeeksforGeeks Output: No Explanation : String (GeeksforGeeks) contains only the alphanumeric characters. Input: $% ^ & amp; @ Output: Yes Explanation : String ($% ^ & amp; @) contains only the punctuation character.
The programs below illustrate the ctype_punct() function. 
Program 1:
// PHP program for checking the given
// the line does not contain
// alphanumeric numeric or numeric or blank
// character  $string1 = 'GeeksforGeeks' ; if (ctype_punct ( $string1 )) echo "Yes" ; else echo " No " ; $string2 = ' $% ^ & amp; @ ' ; if (ctype_punct ( $string2 )) echo "Yes" ; else echo " No " ; ?>
Exit:
No Yes
Program 2:The code for the ctype_punct() function takes an input array of strings that contains integers and a special character.
// PHP program for checking the given
// no string contains
// alphanumeric or numeric or
// empty character $strings = array ( 'Geeks' ,  'Geeks space' , ' @@ ## - / ' , ' 12345' , '' , '& amp ;% @!() ^ ');  
// Checking the above lines
// using ctype_punct()
// function. foreach ( $strings as $test ) { if (ctype_punct ( $test )) echo "Yes" ; else echo " No " ; }  
?>
Exit:
No No No No No Yes
Link: http : //php.net/manual/en/function.ctype-punct.php



Get Solution for free from DataCamp guru