繁体   English   中英

可以看到变量的值,但不能使用它来验证PHP

[英]Can see the value of the variable but can't use it to validate PHP

<?php
function number_of_fb_comments()
{
    return $number = "<fb:comments-count href=" . get_permalink($post->ID) . " ></fb:comments-count>";
}
?>
<?php
function get_fb_comments()
{
    $number = number_of_fb_comments();

    if ($number == 1) {

        echo "<a href =$url#facebook_comments > $number Comment</a></span>";

    } else if ($number > 1) {

        echo "<a href =$url#facebook_comments > $number Comments</a></span>"; 

    } else {

        echo "<a href=$url#facebook_comments>Leave a comment</a> </span>";

    }
} ?>

我正在尝试验证我的facebook注释,但似乎无法在if语句中使用'$ number'对其进行验证,但是我可以回显该值并查看它。

因此它只会进入“其他”部分。

我已经将$ number用作全局变量,并在使用var_dumb($ number)之后

我看到每个帖子都有一系列的内容

 string(104) "0" 
 string(118) "1"
 string(111) "0"

您正在调用的$number返回一个字符串( return $number = "<fb:comments-count href=" ),该字符串不是1>1看来您想要从number_of_fb_comments()返回一些不同的数据。 number_of_fb_comments()功能。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM