Web | This Site

Learning PHP
Advanced PHP
PHP Function Reference
PHP Useful Resources
Selected Reading
© 2011 TutorialsPoint.COM

| Home |  | References |  | Discussion Forums |  | About TP

# PHP Function ctype_space()

## Syntax

ctype_space ( $text );

## Definition and Usage

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

## Paramters

Parameter | Description
--- | ---
text | Required. 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.

Advertisement

Online Image Processing

Indian Baby Names