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

报告相同问题?

悬赏问题

  • ¥20 iqoo11 如何下载安装工程模式
  • ¥15 本题的答案是不是有问题
  • ¥15 关于#r语言#的问题:(svydesign)为什么在一个大的数据集中抽取了一个小数据集
  • ¥15 C++使用Gunplot
  • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 蓝桥杯单片机第十三届第一场,整点继电器吸合,5s后断开出现了问题
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?