gpt4 book ai didi

php - 如果 Post 值等于其他 post 值以外的值,则回显“失败”;?

转载 作者:行者123 更新时间:2023-12-04 18:13:01 25 4
gpt4 key购买 nike

我有两个组合框,一个用于报告得分,一个用于设置进球者,如果在 post['submit'] 上,我该如何做到这一点

如果 $_POST['Score1'] 和 $_POST['Score2']
不等于
$_POST['homegoalscorer1'] 和 $_POST['awaygoalscorer1']
然后回显“失败”;

就像是;

 if(isset($_POST['submit']))   
{
$homescore = $_POST['Score1'];
$awayscore = $_POST['Score2'];

$homegoalscorer = $_POST['homegoalscorer1'];
$awaygoalscorer = $_POST['awaygoalscorer1'];

if '$homescore' + '$awayscore' != $homegoalscorer + $awaygoalscorer {
echo "failed";
}
else {

}
}

有任何想法吗?

最佳答案

变量上的单引号将把该变量引入一个字符串而不执行。你也忘了加括号:

if(isset($_POST['submit']))   {
$homescore = (float)$_POST['Score1'];
$awayscore = (float)$_POST['Score2'];

$homegoalscorer = (float)$_POST['homegoalscorer1'];
$awaygoalscorer = (float)$_POST['awaygoalscorer1'];

if (($homescore+$awayscore) != ($homegoalscorer+$awaygoalscorer)) {
echo "failed";
} else {

}
}

关于php - 如果 Post 值等于其他 post 值以外的值,则回显“失败”;?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12247581/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com