Category Archives: PHP- String check for numeric and alphabet

PHP- String check for numeric and alphabet

This tutorial explains about the PHP function ctype_alpha,ctype_alnum(),is_numeric().

ctype_alpha():

This function returns true(1) if the tested string is alphabet.y using ctype_alpha function in php. We can check or validate alphabetic characters only. Using this function we can check any input coming from insecure ( or any other ) sources. This function is case insensitive so can’t differentiate between lower case and upper case alphabetic characters.

$var=”abctYB”;

if(ctype_alpha($var)){
echo ” This is alphabetic “;
}else{ echo “this is not alphabetic”;}

Also check for
  • ctype_upper() – Check for uppercase character(s)
  • ctype_lower() – Check for lowercase character(s)
  • ctype_alnum()- Check for alpha numeric