dongxun1244 2018-02-09 22:08
浏览 112
已采纳

curl_init()的替代?

I'm trying to debug some code using either of these two intrepreters. The code below runs on my GoDaddy site and produces the appropirate output arrays. But, won't run in either of these intrepreters. Is there a way to modify this code to run in the intrepreters so I can get past line 2 of the code? I inclcuded phpinfo(INFO_MODULES); at the end as an aid.

OR do you know of an online intrepreter that will run this code?

https://3v4l.org/

http://www.runphponline.com/

<?php  
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_HEADER, 0);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            $data = '';

            curl_setopt($ch, CURLOPT_URL, "https://api.iextrading.com/1.0/stock/market/batch?symbols=aapl,tsla,ge&types=quote,earnings,stats");
            $data = curl_exec($ch);
            curl_close($ch);

            $data = json_decode($data, true);

            // debug -------------------------------
            echo '  - ';
            echo (count($data));     // number of elements
            echo " - " . "<br />
";
            var_dump_pre($data);     // dump the array
            echo "-" . "<br />
";
            echo "xxxxxxxxxxxxxx-" . "<br />
";

            function var_dump_pre($mixed = null) {
            echo '<pre>';
            var_dump($mixed);
            echo '</pre>';
            return null;
            }

            phpinfo(INFO_MODULES);
?>
  • 写回答

2条回答 默认 最新

  • du8980919 2018-02-15 17:38
    关注

    Since the code ran on my GoDaddy site I was able to copy the data returned from the '$data = curl_exec($ch);' insruction and assign it to a variable name at the start of the code I'm trying to debug. So, the code I'm trying to debug starts out with the intended incomimg data (and doesn't have to go get it). I can now continue to use any of these three online intrepreters:

    https://3v4l.org/

    http://www.runphponline.com/

    http://phpfiddle.org/

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?