簡體   English   中英

存儲值並檢查值是否為空

[英]Storing value and checking if the value is empty

有沒有一種方法可以檢查值

<?php the_field('max_working_height')?> 

為空或存儲將在我使用acnd檢查是否為空時顯示的值。 如果該值不為空,那么我必須使其執行一組這樣的html代碼和php代碼

    <tr style="height: 25px; margin-left: 10px;">
<td style="margin-left: 10px;"><b>Max
  <?php the_field('max._outreach'); ?></td> 
</tr>

請幫忙。

<?php
$maxWorkingHeight = the_field('max_working_height');

if (false == $maxWorkingHeight) {
    // print your html/php
} else {
    // you can print $maxWorkingHeight here if you need it
}

假設如果未設置字段( nullfalse0或空字符串都是PHP中falsy值的示例),則函數返回falsy值。

如果顯示出您正在使用ACF插件,則the_field()回顯該字段的值。 如果要捕獲字段的值,請使用get_field() 此處查看文檔。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM