2012-02-21 5 views
0

私はcURLエラー番号で取得しようとしていますが、curl_errorno() functionは機能していません。私は1行のスクリプト作成する場合:未定義の関数curl_errorno()を呼び出しますが、cURLがインストールされ、動作しています

curl_errorno(); 

を私はこのエラーを取得する:

Call to undefined function curl_errorno()...

  • のcURLがインストールされている...私は要求がうまく作ってそれを使用することができます。
  • (php.iniので報告されたように)PHP 5.3.6
  • のcURL 7.19.7(php.iniので報告されたように)
  • 私のconfigureコマンドが--with-curl

なぜcurl_errorno()についてどのような考えを含んでい利用できませんか?それが動作するかどうか

print curl_download('http://www.example.org/'); 

はたぶん、ということを試してみる

+3

'curl_errno()'関数の実際の名前があり、それを試してみてくださいコードの下に使用してください。 – drew010

+0

@ drew010、HA!それだった!私は約5回それをチェックした後、それを見逃してどのように考えていない。あなたの答えとして投稿してください。ありがとう! – Brad

+0

PHPマニュアルが正しい機能にあなたを透過的にリダイレクトするのに役立つものではありません。私は古いエイリアスではないことを二重チェックしなければならなかった。コーヒーの時間。 – drew010

答えて

8
curl_errno(); 

ない

curl_errorno(); 
+0

うん、そうだった。ありがとう! – Brad

0

http://www.jonasjohn.de/snippets/php/curl-example.htm

function curl_download($Url){ 

    // is cURL installed yet? 
    if (!function_exists('curl_init')){ 
     die('Sorry cURL is not installed!'); 
    } 

    // OK cool - then let's create a new cURL resource handle 
    $ch = curl_init(); 

    // Now set some options (most are optional) 

    // Set URL to download 
    curl_setopt($ch, CURLOPT_URL, $Url); 

    // Set a referer 
    curl_setopt($ch, CURLOPT_REFERER, "http://www.example.org/yay.htm"); 

    // User agent 
    curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0"); 

    // Include header in result? (0 = yes, 1 = no) 
    curl_setopt($ch, CURLOPT_HEADER, 0); 

    // Should cURL return or print out the data? (true = return, false = print) 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 

    // Timeout in seconds 
    curl_setopt($ch, CURLOPT_TIMEOUT, 10); 

    // Download the given URL, and return output 
    $output = curl_exec($ch); 

    // Close the cURL resource, and free system resources 
    curl_close($ch); 

    return $output; 
} 

それを使用するには...、多分その問題あなたの前のコードで?

+0

マークの答えは良かった。私は 'curl_error'の代わりに' curl_errorno'を使っていました。とにかくありがとう。 – Brad

+1

母 - それは固定されてうれしいよ:) – Chris

-1

、あなたのサーバにインストールされていないCURLまたはCURL拡張子を持つすべての問題を持っている場合は、ちょうど

function get_web_page($url) 
{ 
    $options = array('http' => array(
     'user_agent' => 'spider', // who am i 
     'max_redirects' => 10,   // stop after 10 redirects 
     'timeout'  => 120,   // timeout on response 
    )); 
    $context = stream_context_create($options); 
    $page = @file_get_contents($url, false, $context); 

    $result = array(); 
    if ($page != false) 
     $result['content'] = $page; 
    else if (!isset($http_response_header)) 
     return null; // Bad url, timeout 

    // Save the header 
    $result['header'] = $http_response_header; 

    // Get the *last* HTTP status code 
    $nLines = count($http_response_header); 
    for ($i = $nLines-1; $i >= 0; $i--) 
    { 
     $line = $http_response_header[$i]; 
     if (strncasecmp("HTTP", $line, 4) == 0) 
     { 
      $response = explode(' ', $line); 
      $result['http_code'] = $response[1]; 
      break; 
     } 
    } 

    return $result; 
} 
+0

コード内のいくつかのコメントは、それを簡単になります。 – CCoder

+0

これは問題ではありません。私は、私の質問に掲示された情報でわかるように、cURLをインストールしました。また、私はすでに答えがあります。私は単純に誤った関数名を使用していました。 – Brad

関連する問題