3raser Posted June 16, 2012 Share Posted June 16, 2012 I want to ensure that the data received is set. Is there any other way I can shorten this condition? I was thinking of a for loop, but I'm not sure that'd be considered more efficient. if((!ctype_digit($_GET['forum']) && !ctype_digit($_POST['forum'])) || (!ctype_digit($_GET['id']) && !ctype_digit($_POST['id'])) || (!ctype_digit($_GET['type']) || !ctype_digit($_POST['type']))) $base->redirect('index.php'); Quote Link to comment https://forums.phpfreaks.com/topic/264273-easier-way-to-shorten/ Share on other sites More sharing options...
requinix Posted June 16, 2012 Share Posted June 16, 2012 At only three fields it's not really worth trying to rework it into something that looks simpler but is actually more complicated. However you could use $_REQUEST as it contains both $_GET and $_POST values. And there's a bug in there: pretty sure one of the four ||s should be a &&. Quote Link to comment https://forums.phpfreaks.com/topic/264273-easier-way-to-shorten/#findComment-1354336 Share on other sites More sharing options...
3raser Posted June 16, 2012 Author Share Posted June 16, 2012 At only three fields it's not really worth trying to rework it into something that looks simpler but is actually more complicated. However you could use $_REQUEST as it contains both $_GET and $_POST values. And there's a bug in there: pretty sure one of the four ||s should be a &&. Ah, thank you. And yeah, thanks for pointing that out. Was a small bug. Quote Link to comment https://forums.phpfreaks.com/topic/264273-easier-way-to-shorten/#findComment-1354340 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.