PHP If Post Value is less than or greater than
I have a php booking form which checks to make sure that information has been entered in the boxes before its submitted:
I use the following to check to make sure group has a value in it.
if(!isset($_POST['group']) || trim($_POST['group']) == '')
{
$error.= "Group Size is required<br/>";
}
How can I use an IF statement too check that the value in group is greater than 39 but less than 400?
做就是了
if(strlen(trim($_POST['code'])) >= 39 && strlen(trim($_POST['code'])) < 400)
if(!empty($_POST['group']) && is_numeric($_POST['group']))
{
if($_POST['group'] < 400 && $_POST['group'] > 39)
{
//here you go
}
}
The empty also checks for existence. You should always check the type of the values youre getting, not only if empty - type casting gets done by php for you
Other answer is wrong btw, question is greater than 39, not greater or equal 39
链接地址: http://www.djcxy.com/p/58582.html上一篇: 在两个静态数字之间创建一组数字范围
下一篇: PHP如果Post Value小于或大于