Hi everyone,
I need to check for a couple of different conditions, but want to make my code as simple and efficient as possible.
Basically, I have 4 test numbers, one of which is appended in the URI when the user clicks a test link. For example, the user clicks:
test.php?test_number=1
I want it to be impossible to cause errors on the page by specifying an invalid test number, so I need to make sure that test_number is equal to 1, 2, 3, or 4, and nothing else.
I could do:
if ($test_number != 1 || $test_number != 2 || $test_number != 3 || $test_number != 4) {
header('location: ' . $parent_page);
die();
}
However, that will become pretty cumbersome as more tests are added.
Is there an easier/better way to do this check using a loop?
Thanks for all your help!