troubleshooting Question

I check if $_GET value is valid by seeing if it is in a list of valid values. Do I also need to check if it's an integer, required and/or alphanumeric?

Avatar of dsrnu
dsrnu asked on
PHP
10 Comments2 Solutions267 ViewsLast Modified:
I check if $_GET value is valid by seeing if it is in a list of valid values. Do I also need to check if it's an integer, required and/or alphanumeric?
$_GET['string'] = 'gamma';

$valid_get_values = array('alpha', 'beta');

if (in_array($_GET['string'], $valid_get_values)
{
	// proceed with valid value
}
else
{
	exit();
}


// as opposed to

if (ctype_alpha($_GET['string'] && in_array($_GET['string'], $valid_get_values)
{
	// proceed with valid value
}
else
{
	exit();
}
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 10 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros