dongnai8013 2015-06-18 16:13
浏览 38
已采纳

如果!空语句不工作/事件管理器插件

This is for event manager on wordpress.

The following echos "Website:" even if the field is empty.

<?php
if ( !empty( $EM_Event->event_contact['Url'] ) ) {
    echo $EM_Event->output(' ');
} else {
    echo $EM_Event->output('<strong>Website:</strong> #_CONTACTURL{Url} ') ; 
}
?> </p>

How can I get it to only echo "Website:" if there is a www.website.com entered but not echo "Website:" if there is no www.website.com entered?

  • 写回答

1条回答 默认 最新

  • dongna9185 2015-06-18 16:17
    关注

    You are printing echo $EM_Event->output('<strong>Website:</strong> #_CONTACTURL{Url} ') ; when $EM_Event->event_contact['Url'] IS empty.

    Run a var_dump($EM_Event->event_contact['Url']) right before the if, show us what it prints.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?