如果!空语句崩溃了我的网站

ale*_*nco 3 php if-statement

如果声明我有以下内容:

<a href="#"
   title="<?php the_sub_field('points_description'); ?>"
   class="<?php if(!empty(the_sub_field('points_description'))) {
                  echo 'point-tooltip'; } ?>">
Run Code Online (Sandbox Code Playgroud)

如果我只是包含站点显示的回声部分,但是当我添加if部分(检查功能是否"")时,站点只显示空白.

有什么建议来解决这个问题

Aha*_*ius 6

空函数仅适用于变量.

empty()只检查变量,因为其他任何东西都会导致解析错误.换句话说,以下内容不起作用:empty(trim($ name)).