dongzhui2636 2011-07-15 16:05
浏览 127
已采纳

论证没有传递给特定的功能!

I have this

function twitter_tweets_per_day($user, $rounding = 1) {
    // Helper function to calculate an average count of tweets per day
    $days_on_twitter = (time() - strtotime($user->created_at)) / 86400;
    return round($user->statuses_count / $days_on_twitter, $rounding);
}

function theme_user_header($user) {
    $following = friendship($user->screen_name);
    $tweets_per_day = twitter_tweets_per_day($user, 1);
        if (($tweets_per_day) = 1) 
        {$out = Newbie;} 
        return out;
}

The above works flawlessly. But, this, below, doesn't work! Why? Help!

function twitter_mrank_page($user){
    $tweets_per_day = twitter_tweets_per_day($user, 1);
    if($tweets_per_day >= 0 && $tweets_per_day < 200){
        $out =  "'Addict'";
    }
    else{
        $out = "xxx"
    }

    $status = 'My Rank is '.$out.'! '.$tweets_per_day.' ';
    return $status;
}

It returns 0. Why do the first two codes work, whereas the 3rd (which comes beneath the first two in my code) doesn't?

  • 写回答

1条回答 默认 最新

  • douyin2883 2011-07-15 16:08
    关注

    You only return $status if $tweets_per_data >= 4 && $tweets_per_day < 60

    Everything else will be 0 ... because you don't return anything

    Another good point made ... you are missing a } to close out your function ...

    1. Add debug code
    2. Make sure syntax is correct

    Edit

    After updates by the Question Author, the only other suggestion I have is to ADD DEBUG CODE

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 对于这个问题的算法代码
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据