XII. CURL, Client URL Library
Functions
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
.
There
should
be
a
file
named
"
libcurl.a
"
located
in
the
"lib
"
directory
.
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
curl_init(
)
,
then
you
can
set
all
your
options
for
the
transfer
via
the
curl_exec(
)
and
then
you
finish
off
your
session
using
the
curl_close(
)
.
Here
is
an
example
that
uses
the
CURL
functions
to
fetch
the
PHP
homepage
into
a
file
:
Ejemplo
1
.
Using
PHP
'
s
CURL
module
to
fetch
the
PHP
homepage
?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)
;
?
|
|
-
Tabla de contenidos
-
curl_close
-- Close a 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
-- Perform a CURL session
-
curl_getinfo
-- Get information regarding a specific transfer
-
curl_init
-- Initialize a CURL session
-
curl_setopt
-- Set an option for a CURL transfer
-
curl_version
-- Return the current CURL version