Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 大于和小于精确匹配值_Php - Fatal编程技术网

Php 大于和小于精确匹配值

Php 大于和小于精确匹配值,php,Php,我一直在处理一个函数,验证的目的是确保字段中的输入与定义的$cash变量中的输入完全相同,我成功地使用了大于函数,但这允许值大于用户拥有的值,因此无法获得用户拥有的确切数字,如果用户现金是300,那么任何高于300的值都是有效的,但我希望验证严格按照值进行 add_filter( 'gform_field_validation_9_7', 'custom_validationc', 10, 4 ); function custom_validationc( $result, $value, $f

我一直在处理一个函数,验证的目的是确保字段中的输入与定义的$cash变量中的输入完全相同,我成功地使用了大于函数,但这允许值大于用户拥有的值,因此无法获得用户拥有的确切数字,如果用户现金是300,那么任何高于300的值都是有效的,但我希望验证严格按照值进行

add_filter( 'gform_field_validation_9_7', 'custom_validationc', 10, 4 );
function custom_validationc( $result, $value, $form, $field ) {

$current_user = wp_get_current_user();
$number = $current_user->USERPIN2;

if ( $result['is_valid'] && $value < $number ) {
    $result['is_valid'] = false;
    $result['message'] = 'You must enter exactly the amount on your cash balance.';
}
return $result;
add_filter('gform_field_validation_9_7','custom_validationc',10,4);
函数自定义_验证($result,$value,$form,$field){
$current_user=wp_get_current_user();
$number=$current_user->USERPIN2;
如果($result['is_valid']&&$value<$number){
$result['is_valid']=false;
$result['message']=“您必须准确输入现金余额中的金额。”;
}
返回$result;
}


我的问题是我想要$cash的确切值,而不是使用大于的函数。我尝试了$value==$cash,但没有任何效果。仅在我使用大于函数或小于函数进行验证时有效。

如果需要严格验证,则需要使用运算符“==”,详细信息如下:

此外,还可以使用其他条件,因此,代码可能如下所示:

if ( intval($value) === $cash )
  echo "perfect";


如果(intval($value)===$cash)
=
是一项顺便检查的作业,而不是平等检查。不起作用,我已经更新了完整的代码,也许你可以知道我的标题在哪里。我已经将我的代码更新为完整的代码,这样你就可以知道哪里出了问题,以及如何准确地归档我想要的内容。
if ( intval($value) >= $cash )
  echo "perfect";