douza1373 2016-07-28 23:08
浏览 66
已采纳

我将它上传到我的服务器后,Php curl不起作用

It seems that curl works on my localhost but when I upload it to my server it stops working.

This is when i have it on localhost : enter image description here And this is on the host provider server : enter image description here

I am not a professional developer but i think there can be a problem with the host provider one.com

<?php
require 'kint/Kint.class.php';
$cURL = curl_init('162.243.44.4/server_list.json');
curl_setopt($cURL, CURLOPT_PORT, 3000);
curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true);

$jsondata = curl_exec($cURL);
Kint::dump($jsondata);
$json = json_decode($jsondata, true);



function ping($host,$port=4000,$timeout=6)
    {
        $fsock = fsockopen($host, $port, $errno, $errstr, $timeout);
        if ( ! $fsock )
        {
            return 'Offline';
        }
        else
        {
            return 'Online';
        }
    }

    Kint::dump($json['servers']);
    foreach ($json['servers'] as $js){
        echo  $js['name'] . ' is ' . ping($js['ip']) . ' <br>';
    }
?>
  • 写回答

1条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 关于selenium网页闪退
      • ¥15 怎么用PYTHON解类似于x = y+zx + cy = x+zy + v的方程
      • ¥300 FLASH AS2.0制作一个类似手机上下滑动一样的效果
      • ¥15 为什么使用openFoam 中的icoFoam计算圆柱扰流时出现浮点数例外(核心已转储)
      • ¥15 51单片机外部中断控制数码管
      • ¥15 创建网页里面的图片显示不出来
      • ¥15 语音控制的编写?(语言-c#)
      • ¥15 matlab输入书上的代码运行错误
      • ¥15 matlab怎么做三维曲面
      • ¥50 sph光滑粒子法能否解决阶跃性的问题