开发者

what's wrong with the code? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.
  <?php if (!empty(cutstr($node->content,300))) : ?>
      <div class="pr_teaser">
       <?php echo cutstr($node->content,300); ?>
        </div>
    <?php endif; ?>

what's wrong with the code? the cutstr function is ok. my IDE makes an a alert to this line <?php 开发者_如何学Pythonif (!empty(cutstr($node->content,300))) : ?> is wrong? but i can't find the error.


empty() only checks variables as anything else will result in a parse error. In other words, the following will not work: empty(trim($name)).

From http://php.net/manual/en/function.empty.php

You need to do something like this:

<?php $value=cutstr($node->content,300); if (!empty($value)) : ?>
  <div class="pr_teaser">
   <?php echo $value; ?>
    </div>
<?php endif; ?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜