Created
June 16, 2012 17:10
-
-
Save MikeRogers0/2941974 to your computer and use it in GitHub Desktop.
PHP's Ctype Functions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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