CURL Library



( ZN >= 2.0.0 )

PHP supports the CURL library written by Daniel Stenberg . The CURL library is used to connect to different types of servers and to communicate with different protocols. CURL currently supports http , https , ftp , gopher , telnet , dict , file and ldap protocols. In addition, HTTPS certificates, HTTP POST , HTTP PUT, FTP can be uploaded. It also supports HTTP forms uploads, sessions, cookies, and user and password authentication.

 

# Methods


this init ( String $ url = NULL )
this option ( String $ options , Mixed $ value )
Bool exec ( Void )
String escape ( String $ str )
String unescape ( String $ str )
Mixed info ( String $ opt )
String error ( Void )
String errval ( Int $ errno = 0 )
Int errno ( Void )
Int pause (Scalar  $ bitmask = 0 )
Bool reset ( Void )
Bool close ( Void )
Mixed version ( Scalar $ data = NULL )

 

# Init ( ZN >= 2.0.0 )


Used to start a CURL session.

Parameters

String $ url = NULL Used to set CURLOPT_URL value by default.
return this

Use of

CURL::init()
    ->option('url', 'https://www.ornek.com/')
    ->option('header', 0)
    ->exec();

 

# Option ( ZN> = 2.0.0 )


The CURL specified is used to create an option on the session handle.

Parameters

String $ Option The CURLOPT_ *  option to assign  .
Mixed $ Value Your choice of value.
return this

Use of

CURL::init()
    ->option('url', 'https://www.ornek.com/')
    ->option('post', 1)
    ->option('postfields', ['name' => 'Example'])
    ->exec();

Methodological Options ( ZN> = 5.3.7 )

Options have become configurable with method names. CURLOPT_SSL_VERIFYPEER constants consisting of a combination of more than one sslverifype is ()namely in the form of camelCase it should be written in standard. Because they are optionsCURLOPT_ There is also no need to use your text.

CURL::init()
    ->url('https://www.ornek.com/')
    ->post(1)
    ->postfields(['name' => 'Example'])
    ->header(0)
    ->sslVerifypeer(true)
    ->exec();

As seen above, the options are used with method names and are restructured with parameters.

 

# Exec ( ZN >= 2.0.0 )


Used to run the launched CURL session.

Parameters

void
return Bool

Use of

CURL::init()
    ->option('url', 'https://www.ornek.com/')
    ->option('post', 1)
    ->option('postfields', ['name' => 'Example'])
    ->exec();

 

# Escape ( ZN >= 3.1.7 )


Encodes characters with special content.

Parameters

String $ Str The string to be encoded.
return this

Use of

CURL::init();
echo CURL::escape('Şaban');
9Eab% C5% of 

 

# Unescape ( ZN >= 3.1.7 )


Resolves characters with special content encoded.

Parameters

String $ Str The string to solve.
return this

Use of

CURL::init();
$encode = CURL::escape('Şaban');
echo CURL::unescape($encode);
Plow 

 

# Info ( ZN >= 2.0.0 )


Provides information about the session started.

Parameters

String $ op Name of option to be informed.
return Mixed

Use of

CURL::init('https://www.znframework.com');
output(CURL::info('effective_url'));
I https://www.znframework.co

 

# Error / Errval ( ZN> = 2.0.0 )


CURL gives information about whether there is an error with the session. It works the same in both methods above.

Parameters

void
return String

Use of

CURL::init('https://www.znframework.coms');
CURL::exec();
output(CURL::error());
Could not resolve host: www.znframework.coms

 

# Errno ( ZN >= 2.0.0 )


CURL gives information about the session as an error number.

Parameters

void
return String

Use of

CURL::init('https://www.znframework.coms');
CURL::exec();
output(CURL::errno());
6

 

# Pause ( ZN >= 4.0.0 )


Pause the CURL session.

Parameters

Mixed $ bitmask = 0 It accepts CURLPAUSE_ *  constants as parameters.
return Int

Use of

CURL::init('https://www.znframework.com');
CURL::pause();
CURL::exec();

 

# Reset ( ZN >= 2.0.0 )


Zero any options defined in the CURL session.

Parameters

void
return Bool

Use of

CURL::init('https://www.znframework.com');
CURL::reset();

 

# Close ( ZN> = 2.0.0 )


CURL is used to terminate the session. This is done automatically by the class.

Parameters

void
return Bool

Use of

CURL::init('https://www.znframework.com');
CURL::exec();
CURL::close();

 

# Version ( ZN >= 2.0.0 )


CURL gives version information.

Parameters

Mixed $ data = NULL Version info option.
return Mixed

Use of

CURL::init('https://www.znframework.com')->exec();

output(CURL::version());
version_number => integer 471297 (length = 6 ) ,
age => integer 3 (length = 1 ) ,
features => integer 266141 (length = 6 ) ,
ssl_version_numb is => integer 0 (length = 1 ) ,
version => string '7:49 .1 ' (length = 8 ) ,
host => string ' i386-pc-win32 ' (Length = 15 ) ,
ssl_versio of => string 'openSSL / 1.0.2h' (length = 16 ) ,
libz_versio of => string '1.2.8' (length = 7 ) ,
protocols => array
(
        0 => string 'dict' (length = 6 ) ,
        1 => string 'file' (length = 6 ) ,
        2 => string 'ftp' (length= 5 ) ,
        3 => string 'ftps' (length = 6 ) ,
        4 => string "gopher" (length = 8 ) ,
        5 => string 'http' (length = 6 ) ,
        6 => string 'https' (length = 7 ) ,
        7 => string 'imap' (length = 6 ) ,
        8 => string 'IMAP' (length = 7 ) ,
        9 => string "LDAP (length = 6 ) ,
        10 => string " POP3 (length = 6 ) ,
        11 => string 'POP3s' (length = 7 ) ,
        12 = > string 'rtsp' (length = 6 ) ,
        13 => string 'scp' (length = 5 ) ,
        14 => String 'SFTP (length = 6 ) ,
        15 => string ' SMTP ' (length = 6 ) ,
        16 => string ' SMTPs' (length = 7 ) ,
        17 => string "telnet" (length = 8 ) ,
        18 => string 'tftp' (length = 6 ) ,
)
Note: If you do not have enough experience about CURL Operations  , visit php.net for CURL Usage .