PHP Ctype (Character type) capacities: Here, we will find out about the character type (Ctype) works in PHP.
Ctype capacities
PHP gives a portion of the implicit capacities, which are utilized to check the characters in the string, for example, to check whether a string contains the characters of explicit sorts.
Rundown of the Ctype capacities in PHP
Here, is the rundown of the PHP Ctype capacities…
ctype_alnum() – Checks whether given string contains all letters in order or numbers.
ctype_alpha() – Checks whether given string contains all letters in order.
ctype_digit() – Checks whether given string contains all digits.
ctype_space() – Checks whether given string contains spaces (whitespaces, tab, new line and so forth).
ctype_lower() – Checks whether given string contains every single lowercase character.
ctype_upper() – Checks whether given string contains every single capitalized character.
ctype_punct() – Checks whether given string contains all accentuation characters.
ctype_xdigit() – Checks whether given string contains every single hexadecimal digit.
ctype_print() – Checks whether given string contains every single printable character.
ctype_graph() – Checks whether given string contains every single printable character anticipate space.
ctype_cntrl() – Checks whether given string contains all control characters.
PHP Ctype capacities Example
<?php
echo (ctype_alnum("Hello123")."\n");
echo (ctype_alpha("Helloworld")."\n");
echo (ctype_digit("01234")."\n");
echo (ctype_space("\r\n \t")."\n");
echo (ctype_lower("helloworld")."\n");
echo (ctype_upper("HELLOWORLD")."\n");
echo (ctype_punct("!@#~*&(){}")."\n");
echo (ctype_xdigit("aaff01290")."\n");
echo (ctype_print("Hello world!")."\n");
echo (ctype_graph("Hello123!@#")."\n");
echo (ctype_cntrl("\x00\x1F\x7F\r\n")."\n");
?>
Output
1
1
1
1
1
1
1
1
1
1
1