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_alpha()

## Syntax

ctype_alpha ( $text );

## Definition and Usage

Checks if all of the characters in the provided string, text, are alphabetic. In the standard C locale letters are just [A-Za-z] and ctype_alpha() is equivalent to (ctype_upper($text) || ctype_lower($text)) if $text is just a single character.

## Paramters

Parameter | Description
--- | ---
text | Required. The tested string.

## Return Value

Returns TRUE if every character in text is a letter, FALSE otherwise.

## Example

Try out following example:

    <?php
    $strings = array('KjgWZC', 'arf12');
    foreach ($strings as $testcase) {
     if (ctype_alpha($testcase)) {
         echo "$testcase consists of all letters.<br />";
     } else {
         echo "$testcase does not have all letters.<br />";
     }
    }
    ?>

This will produce following result:

    KjgWZC consists of all letters.
    arf12 does not have all letters.

Advertisement

Online Image Processing

Indian Baby Names