Is there a way to test a range without doing this redundant code:
if ($int>$min && $int<$max)
?
Like a function:
There is no builtin function, but you can easily achieve it by calling the functions min() and max() appropriately.
min()
max()
// Limit integer between 1 and 100000 $var = max(min($var, 100000), 1);