doushi1900 2012-10-13 00:11
浏览 30
已采纳

if语句不工作继续触发函数

I have a problem with my script im using. the if $addcount is not working. it continues to fire the insertMessage function when i dont want it to. Any ideas why?

if(($result->data != '') && ($result->data != null)) {
    $wallCount = 0;
    $addCount = 0;
    foreach($result->data as $thread){
        $wallCount++;
        $fromId = $thread->from->id;
        $message = $thread;
        if($fromId == $user['Id']){
            if($addCount < 100) {
                insertMessage($user['Id'], $message, $user['Num']);
                $addCount++;
                sleep(1);
            }
        }
     }
}
  • 写回答

1条回答 默认 最新

  • dougezhua0017 2012-10-13 00:25
    关注

    From your script, it will call insertMessage 100 times (0-99). Before the if statement, echo the counter to see what it is doing:

    ...
    echo $addCount."<br />";
    if($addCount < 100) {
    ...
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画