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: Sun, 21 Jun 2009

view this page in

После сборки PHP с поддержкой CURL можно использовать функции CURL functions. Работа с CURL всегда начинается с вызова curl_init(), затем устанавливаются необходимые параметры с помощью curl_setopt(), и выполняется требуемая операция вызовом curl_exec(), после чего вызовом curl_close() сеанс работы завершается. Приведенный ниже пример использует функции CURL для сохранения стартовой страницы сайта example.com в файл:

Пример #1 Использования модуля 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
Использования модуля CURL для сохранения стартовой страницы example.com
cmnajs at gmail dot com
07-Jan-2009 11: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: Sun, 21 Jun 2009
 
 
show source | credits | sitemap | contact | advertising | mirror sites