Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP CURL CURL“u exec returns”;不能';t解析主机“;www.~.com";。是否启用了卷曲?_Php_Curl - Fatal编程技术网

PHP CURL CURL“u exec returns”;不能';t解析主机“;www.~.com";。是否启用了卷曲?

PHP CURL CURL“u exec returns”;不能';t解析主机“;www.~.com";。是否启用了卷曲?,php,curl,Php,Curl,此函数适用于本地主机,但不适用于我的远程服务器 我向服务器管理员询问了这一点,它告诉我PHP CURL已经启用,一切都应该正常 代码如下: 我正在测试的$url是: $url = "http://bus.go.kr/getSubway_6.jsp?statnId=1003000323&subwayId=1003" 以下是函数: function file_get_html_using_cURL($url) { if (!function_exists('curl_init'))

此函数适用于本地主机,但不适用于我的远程服务器

我向服务器管理员询问了这一点,它告诉我PHP CURL已经启用,一切都应该正常

代码如下:

我正在测试的$url是:

$url = "http://bus.go.kr/getSubway_6.jsp?statnId=1003000323&subwayId=1003"
以下是函数:

function file_get_html_using_cURL($url) {
    if (!function_exists('curl_init')){ 
        die('CURL is not installed!');
    }

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPGET, 1);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_DNS_USE_GLOBAL_CACHE, false );
    curl_setopt($ch, CURLOPT_DNS_CACHE_TIMEOUT, 2 );
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, faslse);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);



    $output = curl_exec($ch);

    if(curl_errno($ch)){
        echo 'Curl error: ' . curl_error($ch);
        echo "\n--------------------\n";
        print_r(curl_getinfo($ch));
        echo "\n--------------------\n";
    }

    $output = str_get_html($output); // <-- Important line to convert string into object!
    curl_close($ch);

    return $output;
}
我不知道为什么这在远程服务器上不起作用


我该怎么办?

curl
已启用,并且在您的情况下运行良好。不幸的是,它运行的服务器无法解析名称
bus.go.kr
。在此上下文中解析意味着查找名称已知的Internet主机的IP地址

这个问题可能有很多根源。如果它是永久的,那么服务器可能配置错误。如果是暂时的,那么可能是连接问题


例如,您可以使用不同的URL进行更多检查,并查看得到的结果。如果您无法访问其中任何一个,那就是配置问题。

尝试使用curl\u setopt($ch,CURLOPT\u SSL\u VERIFYHOST,FALSE)

确保你的机器上有卷曲功能吗?哇。您刚刚发布了运行古老、不受支持的PHP5.3.3的服务器的IP地址,该服务器可能包含一系列公开的安全问题。请从internet上删除此计算机!这看起来像是该系统的名称解析问题。@UlrichEckhardt谢谢。我删除了IP地址,但无论如何它是一个免费服务器。它也可能需要使用代理才能工作。使用$url=”“返回“无法解析主机‘www.google.com’”。那么这是配置问题吗?你能教我如何以及如何改变配置吗?PHP没有什么问题,它是在操作系统级别上。您应该询问系统管理员。正如@DanielStenberg所建议的,您可能需要将请求发送到代理服务器,因为您运行的代码似乎无法直接访问Internet。您可以通过询问您的系统管理员来了解情况(以及代理服务器的名称/地址)。然后,您必须在代码中添加与
CURLOPT_PROXY
相关的
curl
选项。请编辑您的答案,解释为什么这与问题中的行为不同?
Curl error: Couldn't resolve host 'bus.go.kr'
--------------------
Array
(
[url] => http://bus.go.kr/getSubway_6.jsp?statnId=1003000323&subwayId=1003
[content_type] => 
[http_code] => 0
[header_size] => 0
[request_size] => 0
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0
[namelookup_time] => 0
[connect_time] => 0
[pretransfer_time] => 0
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => -1
[upload_content_length] => -1
[starttransfer_time] => 0
[redirect_time] => 0
[certinfo] => Array
    (
    )

)

--------------------