[英]Variable not working when an integer works fine in Gravity Forms GFAPI::get_entries filter
我试图理解为什么包含 integer 的变量不能用于替换 GFAPI::get_entries field_filters 值中的 integer。 这有效:
$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);
在有效的情况下,我的 arrays 打印正确,在无效的情况下,我得到“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}";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.