PHP | ctype_space() Function Last Updated : 06 Feb, 2023 Comments Improve Suggest changes Like Article Like Report A ctype_space() function in PHP is used to check whether each and every character of a string is whitespace character or not. It returns True if the all characters are white space, else returns False. Syntax : ctype_space(string text) Parameter Used: text :- It is a mandatory parameter which specifies the string. Return Value: Returns TRUE if every character in text contains white space, return false otherwise. the blank character also includes tab, carriage, vertical tab, line feed, and form feed characters. Examples: Input : \r Output : Yes Explanation: \r is create white space Input : abc\r Output : No Explanation: characters "abc" are not white space Below programs illustrate the ctype_space() function. Program 1: taking a single string php <?php // PHP program to check given string is // whitespace character or not $string = "/n/t/r"; if (ctype_space($string)) echo "Yes \n"; else echo "No \n"; ?> Output:No Program: 2 Taking an array of string and checking for whitespace using ctype_space() function PHP <?php // PHP program to check given string is // whitespace character or not $strings = array('\n\y\t\x\u\o', "\ngfg\n", "\t"); // Checking above given strings //by used of ctype_space()function . foreach ($strings as $testcase) { if (ctype_space($testcase)) { echo "Yes \n"; } else { echo "No \n"; } } ?> Output:No No Yes Program: 3 Takes an example ctype_space() function how to work string in both single quotes ' ' and double quotes " " symbol. PHP <?php // PHP program to check given string is // whitespace character or not $strings = array('\n', "\n", '\t', "\t"); // Checking above given strings // by used of ctype_space()function . foreach ($strings as $testcase) { if (ctype_space($testcase)) { echo "Yes \n"; } else { echo "No \n"; } } ?> Output:No Yes No Yes References :http://php.net/manual/en/function.ctype-space.php Comment More infoAdvertise with us Next Article PHP | ctype_space() Function jit_t Follow Improve Article Tags : Web Technologies PHP PHP-function Similar Reads PHP | ctype_punct() Function The ctype_punct() is an inbuilt function in PHP which is used to check printable character which is not whitespace or an alphanumeric character. Every character in a string is printable, but neither alphanumeric, digit or blank then return True otherwise return False. Syntax: bool ctype_punct ( $tex 2 min read PHP | ctype_punct() Function The ctype_punct() function in PHP is used to check if all of the characters of a given string are punctuation characters or not. If all characters are punctuation characters then this function return TRUE, otherwise, returns FALSE. Note: The punctuation characters are, period, comma, question mark, 2 min read PHP | ctype_upper() Function The ctype_upper() function in PHP used to check each and every character of a given string is in uppercase or not. If the string in upper case then it returns TRUE otherwise returns False. Syntax: ctype_upper (string text) Parameter Used:- $text : The tested string. Return Value: Function returns Tr 2 min read PHP | ctype_print() Function The ctype_print() Function in PHP used to check each and every character of a string are visible or not. If all characters of string are visible then returns TRUE , else if there are any control character then return FALSE. Control Character: A character that does not represent a printable character 2 min read 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 2 min read Like