what's wrong with the code? [closed]
<?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; ?>
精彩评论