doutuo3935 2015-07-17 21:22
浏览 32

条件=真时的Php循环[关闭]

I have a php file which basically reads a page using JSON and a variable is returned to it (pending/paid/expired). now my simple requirement is if the returned variable is paid/expired the respective actions for them should be taken and the loop should not be repeated but if the response is pending the code should recheck after 10 seconds. A similar cycle then happens again and so on till the loop is stopped(by receiving either a expired/paid response.

here is the code i prepared for it using the examples i found at various places but this doesnt seem to work correctly.. pls guide..

    while($end==0) {        
        $json = file_get_contents('http://old.kbourbaki.com/xlisteningpageprestashop.aspx?yyyyyyy');
        $obj = json_decode($json);
        $result=$obj->response;
        echo($result);
        if ($result=='paid') {
            p('Order Successfull');
            $end=1;
        } elseif ($result=='expired' ) {
            p('status = expired');
            $end=1;//ex

    } else {
        d('status = Pending');
        sleep(10);
    }
}

CODE UPDATED extra '{' removed

  • 写回答

2条回答 默认 最新

  • dormbaf90464 2015-07-17 21:32
    关注

    You have one too many curly braces. The proper elseif and else block should look like this

    } elseif ($result=='expired' ) {
        p('status = expired');
        $end=1;//ex
    } else {
    

    It would help you a lot if you properly formatted your code.

    评论

报告相同问题?

悬赏问题

  • ¥15 mmocr的训练错误,结果全为0
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀