ctype_digit and ctype_alnum

ctype_digit and ctype_alnum

ctype_digit(string text)
This function is used to check whether the argument is decimal, If the every character in the argument is digit it will return TRUE otherwise it will return false.

Example:
$num = “1234″;
echo ctype_digit($num);

$num = “1234asd”;
echo ctype_digit($num);

In the above code first echo prints 1, because num contains only digits. The second echo will prints nothing, because num contains some letters also.

ctype_alnum ( string text)
This fucntion is used to chcek whether the argument contains alpha numeric characters only. It will return TRUE if the every character in the argument is either digit or letter. Otherwise it returns nothing.

Example:
$num = “1234asd”;
echo ctype_alnum($num);

Above will print 1, because $num contains digits and letters only.

Leave a Reply


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.