Php - How to use ctype function, Validate numeric or sting value


How to use ctype function
How to validate the given string using ctype function?

Normally I used to use preg function to validate the string. Some days ago I rad in php manual that the preg function is slower than other validating function, but still has its own pons and cons. Today I came across a new function called ctype which ca be used to validate the arguments or string. The ctype_alnum is used to calculate the alpha numeric characters and ctype_digit is used to validate the numiric values. Hope the below example will giva you an idea about the ctype function.

$word="w3calculator";
if(ctype_alnum($word))
echo "has alpha numeric characters";
else
echo "has no alphanumerica characters";

Php - Validate numeric or sting value
The topic on Php - How to use ctype function is posted by - Math
Hope you have enjoyed, Php - How to use ctype function . Thanks for your time.

All rights reserved. © www.w3calculator.com