PHP - Function ctype_alpha()


Advertisements


Syntax

ctype_alpha ( $text );

Definition and Usage

It checks if all of the characters in the provided string, text, are alphabetic.

Parameters

Sr.No Parameter & Description
1

text(Required)

The tested string.

Return Value

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

Example

Try out following example −

Live Demo
<?php
   $strings = array('example', 'example1234');
   
   foreach ($strings as $test) {
      if (ctype_alpha($test)) {
         echo "$test consists of all letters. \n";
      }else {
         echo "$test does not have all letters. \n";
      }
   }
?> 

This will produce the following result −

example consists of all letters.
example1234 does not have all letters.

php_function_reference.htm

Advertisements