Copyright © tutorialspoint.com

PHP Function ctype_space()

previous
Advertisements

Syntax

ctype_space ( $text );

Definition and Usage

This function checks if all of the characters in the provided string, text, creates whitespace.

Paramters

ParameterDescription
textRequired. The tested string.

Return Value

Returns TRUE if every character in text creates some sort of white space, FALSE otherwise. Besides the blank character this also includes tab, vertical tab, line feed, carriage return and form feed characters.

Example

Try out following example:

<?php
$strings = array('\n\r\t', '\narf12' );
foreach ($strings as $testcase) {
 if (ctype_space($testcase)) {
     echo "$testcase consists of all whitespace characters.<br />";
 } else {
     echo "$testcase does not have all whitespace characters.<br />";
 }
}
?> 

This will produce following result:

\n\r\t consists of all whitespace characters.
\narf12 does not have all whitespace characters.
previous

Copyright © tutorialspoint.com