Experts Exchange connects you with the people and services you need so you can get back to work.
<?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
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.