Join Up!
91771 members and counting!

 
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links 
search for in the  
previouscrack_opendictcurl_closenext
Last updated: Sun, 27 Oct 2002
view the printer friendly version or the printer friendly version with notes or change language to German | Spanish

XII. Funkce pro práci s CURL, Client URL Library

PHP podporuje libcurl, knihovnu vytvořenou Danielem Stenbergem, která umožňuje spojení a komunikaci s mnoha různými typy serverů v mnoha různých typech protokolů. libcurl v současné době podporuje http, https, ftp, gopher, telnet, dict, file a ldap protokoly. libcurl také podporuje HTTPS certifikáty, HTTP POST, HTTP PUT, FTP uploady (toto umožňuje i ftp extenze PHP), HTTP formulářové uploady, proxy, cookies a user+password autentikaci.

Pokud chcete používat CURL funkce, musíte nainstalovat CURL. PHP vyžaduje použití CURL 7.0.2-beta nebo vyšší. S verzemi CURL staršími než 7.0.2-beta PHP nebude pracovat.

Dále musíte PHP zkompilovat s --with-curl[=DIR], kde DIR je umístění adresáře obsahujícího lib a include adresáře. V "include" adresáři by měl být adresář pojmenovaný "curl", který by měl obsahovat soubory easy.h and curl.h. V adresáři "lib" by měl být soubor pojmenovaný "libcurl.a".

Tyto funkce byly přidány v PHP 4.0.2.

Pokud máte PHP zkompilované s podporou CURL, můžete začít používat CURL funkce. Základní principem těchto funkcí je, že pomocí curl_init() inicializujete CURL session, potom pomocí curl_exec() nastavíte hodnoty přenosu a nakonec session zavřete pomocí curl_close(). Následuje ukázka, která využíva CURL funkce ke stažení homepage PHP do souboru:

Příklad 1. Použití CURL extenze ke stažení homepage PHP

<?php

$ch = curl_init ("http://www.php.net/");
$fp = fopen ("php_homepage.txt", "w");

curl_setopt ($ch, CURLOPT_FILE, $fp);
curl_setopt ($ch, CURLOPT_HEADER, 0);

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

Obsah
curl_close -- Zavřít CURL session
curl_errno -- Return an integer containing the last error number
curl_error --  Return a string containing the last error for the current session
curl_exec -- Provést CURL session
curl_getinfo --  Get information regarding a specific transfer
curl_init -- Inicializovat CURL session
curl_setopt -- Nastavit parametr CURL transferu
curl_version -- Vrátit verzi CURL
User Contributed Notes
Funkce pro práci s CURL, Client URL Library
add a note about notes
There are no user contributed notes for this page.
previouscrack_opendictcurl_closenext
Last updated: Sun, 27 Oct 2002
Copyright © 2001, 2002 The PHP Group
All rights reserved.
This mirror generously provided by: http://phpbuilder.com/
Last updated: Thu Oct 31 18:34:28 2002 EST