Home » PHP

PHP Ctype (Character type) functions

PHP Ctype (Character type) functions: Here, we are going to learn about the character type (Ctype) functions in PHP.
Submitted by IncludeHelp, on February 04, 2019

Ctype functions

PHP provides some of the built-in functions, which are used to verify the characters in the string i.e. to check whether a string contains the characters of specific types.

List of the Ctype functions in PHP

Here, is the list of the PHP Ctype functions...

ctype_alnum() - Checks whether given string contains all alphabets or numbers.

ctype_alpha() - Checks whether given string contains all alphabets.

ctype_digit() - Checks whether given string contains all digits.

ctype_space() - Checks whether given string contains spaces (whitespaces, tab, new line etc).

ctype_lower() - Checks whether given string contains all lowercase characters.

ctype_upper() - Checks whether given string contains all uppercase characters.

ctype_punct() - Checks whether given string contains all punctuation characters.

ctype_xdigit() - Checks whether given string contains all hexadecimal digits.

ctype_print() - Checks whether given string contains all printable characters.

ctype_graph() - Checks whether given string contains all printable characters expect space.

ctype_cntrl() - Checks whether given string contains all control characters.

PHP Ctype functions 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("[email protected]#~*&(){}")."\n");
	echo (ctype_xdigit("aaff01290")."\n");
	echo (ctype_print("Hello world!")."\n");
	echo (ctype_graph("[email protected]#")."\n");
	echo (ctype_cntrl("\x00\x1F\x7F\r\n")."\n");	
?>

Output

1
1
1
1
1
1
1
1
1
1
1




Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.