[英]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.