downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

cURL 関数> <
Last updated: Fri, 13 Nov 2009

view this page in

PHP を cURL サポート機能付きでコンパイルすると、 curl 関数を使用可能となります。cURL 関数の基本的な使用法は、 curl_init()により cURL セッションを初期化、 curl_setopt() により転送時のオプションを設定、 続いてcurl_exec() により転送を実行し、 curl_close() によりセッションを終了するというものになります。 cURL 関数を使用して example.com ホームページをファイルに取得する例を示します。

例1 PHP の cURL モジュールを使用して example.com のホームページを取得する

<?php

$ch 
curl_init("http://www.example.com/");
$fp fopen("example_homepage.txt""w");

curl_setopt($chCURLOPT_FILE$fp);
curl_setopt($chCURLOPT_HEADER0);

curl_exec($ch);
curl_close($ch);
fclose($fp);
?>



add a note add a note User Contributed Notes
PHP の cURL モジュールを使用して example.com のホームページを取得する
cmnajs at gmail dot com
08-Jan-2009 08:57
Following code returns the curl output as a string.

<?php
       
// create curl resource
       
$ch = curl_init();

       
// set url
       
curl_setopt($ch, CURLOPT_URL, "example.com");

       
//return the transfer as a string
       
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

       
// $output contains the output string
       
$output = curl_exec($ch);

       
// close curl resource to free up system resources
       
curl_close($ch);     
?>

cURL 関数> <
Last updated: Fri, 13 Nov 2009
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites