Skip to content

Instantly share code, notes, and snippets.

@MikeRogers0
Created June 16, 2012 17:10
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save MikeRogers0/2941974 to your computer and use it in GitHub Desktop.
PHP's Ctype Functions
<?php
// Check if input is alphanumeric (letters and numbers)
ctype_alnum('abcdef1234'); // This returns TRUE
ctype_alnum('£%^&ab2'); // This on the otherhand returns FALSE
// check if input is alpha (letters)
ctype_alpha('dssfsdf'); // returns TRUE
ctype_alpha('12345dssfsdf'); // Returns FALSE
?>
<?php
// Check if the input is numeric
ctype_digit('1234'); // TRUE
ctype_digit('1as2d34f'); // FALSE
// Uppercase
ctype_upper('HELLO'); // TRUE
ctype_upper('hElLo'); // FALSE
// Lowercase
ctype_lower('hello'); // TRUE
ctype_lower('HeLLo'); // FALSE
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment