当整数在 Gravity Forms GFAPI::get_entries 过滤器中正常工作时变量不起作用
Variable not working when an integer works fine in Gravity Forms GFAPI::get_entries filter
我试图理解为什么包含整数的变量只能用来替换 GFAPI::get_entries field_filters 值中的整数。
这有效:
$search_criteria = array(
'status' => 'active',
'field_filters' => array(
'mode' => 'any',
array(
'key' => 'gpnf_entry_parent',
'value' => '72'
)
)
);
这不起作用:
$child_entry_ID = "{entry_id}";
其中 $child_entry_ID 是 72。当然
echo $child_entry_ID . "<br />";
打印“72”
$search_criteria = array(
'status' => 'active',
'field_filters' => array(
'mode' => 'any',
array(
'key' => 'gpnf_entry_parent',
'value' => $child_entry_ID
)
)
);
我是这样用的
$entry2 = GFAPI::get_entries(33, $search_criteria);
print_r($entry2);
在有效的情况下,我的数组打印正确,在无效的情况下,我得到“Array()。
所以当我输入 $child_entry_ID 时似乎是:
$child_entry_ID = "{entry_id}";
它回显为一个整数(在本例中为 72),但不解释为结果 (72),而是解释为字符串 ({entry_id})。
我使用函数 rgar 来改变 $child_entry_ID :
$child_entry_ID = rgar( $entry, 'id' );
这在值真正解释为结果 (72) 并且我的搜索条件解释正确的情况下有效。
我知道这是旧的,但不应该
$child_entry_ID = "{entry_id}";
实际上是:
$child_entry_ID = "{$entry_id}";
我试图理解为什么包含整数的变量只能用来替换 GFAPI::get_entries field_filters 值中的整数。 这有效:
$search_criteria = array(
'status' => 'active',
'field_filters' => array(
'mode' => 'any',
array(
'key' => 'gpnf_entry_parent',
'value' => '72'
)
)
);
这不起作用:
$child_entry_ID = "{entry_id}";
其中 $child_entry_ID 是 72。当然
echo $child_entry_ID . "<br />";
打印“72”
$search_criteria = array(
'status' => 'active',
'field_filters' => array(
'mode' => 'any',
array(
'key' => 'gpnf_entry_parent',
'value' => $child_entry_ID
)
)
);
我是这样用的
$entry2 = GFAPI::get_entries(33, $search_criteria);
print_r($entry2);
在有效的情况下,我的数组打印正确,在无效的情况下,我得到“Array()。
所以当我输入 $child_entry_ID 时似乎是:
$child_entry_ID = "{entry_id}";
它回显为一个整数(在本例中为 72),但不解释为结果 (72),而是解释为字符串 ({entry_id})。 我使用函数 rgar 来改变 $child_entry_ID :
$child_entry_ID = rgar( $entry, 'id' );
这在值真正解释为结果 (72) 并且我的搜索条件解释正确的情况下有效。
我知道这是旧的,但不应该
$child_entry_ID = "{entry_id}";
实际上是:
$child_entry_ID = "{$entry_id}";