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条)

报告相同问题?

悬赏问题

  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 UE5#if WITH_EDITOR导致打包的功能不可用
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真
  • ¥15 mars2d在vue3中的引入问题
  • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面
  • ¥15 算法题:数的划分,用记忆化DFS做WA求调