<HTML ><HEAD ><TITLE >CURL, Client URL Library Functions</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="Manual de PHP" HREF="index.html"><LINK REL="UP" TITLE="Referencia de las Funciones" HREF="funcref.html"><LINK REL="PREVIOUS" TITLE="crack_opendict" HREF="function.crack-opendict.html"><LINK REL="NEXT" TITLE="curl_close" HREF="function.curl-close.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></HEAD ><BODY CLASS="reference" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >Manual de PHP</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.crack-opendict.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.curl-close.html" ACCESSKEY="N" >Siguiente</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="reference" ><A NAME="ref.curl" ></A ><DIV CLASS="TITLEPAGE" ><H1 CLASS="title" >XII. CURL, Client URL Library Functions</H1 ><DIV CLASS="PARTINTRO" ><A NAME="curl.partintro" ></A ><P > PHP supports libcurl, a library, created by Daniel Stenberg, that allows you to connect and communicate to many different types of servers with many different types of protocols. libcurl currently supports the http, https, ftp, gopher, telnet, dict, file, and ldap protocols. libcurl also supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading (this can also be done with PHP's ftp extension), HTTP form based upload, proxies, cookies and user+password authentication. </P ><P > In order to use the CURL functions you need to install the <A HREF="http://curl.haxx.se/" TARGET="_top" >CURL</A > package. PHP requires that you use CURL 7.0.2-beta or higher. PHP will not work with any version of CURL below version 7.0.2-beta. </P ><P > To use PHP's CURL support you must also compile PHP <TT CLASS="option" >--with-curl[=DIR]</TT > where DIR is the location of the directory containing the lib and include directories. In the "include" directory there should be a folder named "curl" which should contain the easy.h and curl.h files. There should be a file named "libcurl.a" located in the "lib" directory. </P ><P > These functions have been added in PHP 4.0.2. </P ><P > Once you've compiled PHP with CURL support, you can begin using the curl functions. The basic idea behind the CURL functions is that you initialize a CURL session using the <A HREF="function.curl-init.html" ><B CLASS="function" >curl_init()</B ></A >, then you can set all your options for the transfer via the <A HREF="function.curl-exec.html" ><B CLASS="function" >curl_exec()</B ></A > and then you finish off your session using the <A HREF="function.curl-close.html" ><B CLASS="function" >curl_close()</B ></A >. Here is an example that uses the CURL functions to fetch the PHP homepage into a file: <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN10504" ></A ><P ><B >Ejemplo 1. Using PHP's CURL module to fetch the PHP homepage</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="php" ><?php $ch = curl_init ("http://www.php.net/"); $fp = fopen ("php_homepage.txt", "w"); curl_setopt ($ch, CURLOPT_INFILE, $fp); curl_setopt ($ch, CURLOPT_HEADER, 0); curl_exec ($ch); curl_close ($ch); fclose ($fp); ?></PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ></DIV ><DIV CLASS="TOC" ><DL ><DT ><B >Tabla de contenidos</B ></DT ><DT ><A HREF="function.curl-close.html" >curl_close</A > -- Close a CURL session</DT ><DT ><A HREF="function.curl-errno.html" >curl_errno</A > -- Return an integer containing the last error number</DT ><DT ><A HREF="function.curl-error.html" >curl_error</A > -- Return a string containing the last error for the current session </DT ><DT ><A HREF="function.curl-exec.html" >curl_exec</A > -- Perform a CURL session</DT ><DT ><A HREF="function.curl-getinfo.html" >curl_getinfo</A > -- Get information regarding a specific transfer </DT ><DT ><A HREF="function.curl-init.html" >curl_init</A > -- Initialize a CURL session</DT ><DT ><A HREF="function.curl-setopt.html" >curl_setopt</A > -- Set an option for a CURL transfer</DT ><DT ><A HREF="function.curl-version.html" >curl_version</A > -- Return the current CURL version</DT ></DL ></DIV ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.crack-opendict.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Inicio</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.curl-close.html" ACCESSKEY="N" >Siguiente</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >crack_opendict</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="funcref.html" ACCESSKEY="U" >Subir</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >curl_close</TD ></TR ></TABLE ></DIV ></BODY ></HTML >