[英]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.