Last Updated: February 25, 2016
·
726
· danielerigo

Easy check on PHP input

You can use this native PHP functions to sanitize users input in your code, fast and easy:

Check for alphabetic character(s):
ctype_alpha

Check for numeric character(s):
ctype_digit

Check for alphanumeric character(s):
ctype_alnum

Check for character(s) representing a hexadecimal digit:
ctype_xdigit

Check for uppercase character(s):
ctype_upper

Check for lowercase character(s):
ctype_lower

Check for lowercase character(s) (e.g. line feed, tab, escape.) ("\n\r\t"):
ctype_cntrl

Checks if all of the characters in the provided string creates visible output:
ctype_graph

Check for any printable character which is not whitespace or an alphanumeric character:
ctype_punct

Checks if all of the characters in the provided string creates whitespace:
ctype_space

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

Most application security programs still stop at the repository. The page a visitor loads can run third-party scripts that read the DOM, change a checkout, or steal a session after the deploy already looks clean.

Security insights from Cside