[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More
Experts Exchange Solution brought to you by
"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.
<?php // demo/temp_kgp43.php
* See http://www.experts-exchange.com/Programming/Languages/Scripting/PHP/Q_28629031.html
* Limit Integer Values in PHP
// Receive the request input, cast it to integer or PHP FALSE
echo PHP_EOL . "PLEASE ENTER AN INTEGER";
$val = !empty($_GET['q']) ? (int)$_GET['q'] : FALSE;
// If there is non-FALSE, we have usable input!
if ($val !== FALSE)
if ($val < -360)
echo PHP_EOL . "$val IS BELOW THE ALLOWABLE MINIMUM";
elseif ($val > +360)
echo PHP_EOL . "$val IS ABOVE THE ALLOWABLE MAXIMUM";
echo PHP_EOL . "$val IS ACCEPTABLE";
// CREATE THE ORM TO RECEIVE INPUT
$form = <<<EOD
Enter an integer between -360 and +360:
<input name="q" />
<input type="submit" />
Open in new window
Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.