Tutorials Point


  Learning PHP
  Advanced PHP
  PHP Function Reference
  PHP Useful Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

PHP Function ctype_alpha()


previous

Advertisements

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

ParameterDescription
textRequired. 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.

previous Printer Friendly

Advertisements


  

Advertisements