国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home php教程 php手冊 PHP CURL函數(shù)庫第1/2頁

PHP CURL函數(shù)庫第1/2頁

Jun 13, 2016 pm 12:25 PM
curl php session closure function Library copy connect

curl_close — 關(guān)閉一個curl會話
curl_copy_handle — 拷貝一個curl連接資源的所有內(nèi)容和參數(shù)
curl_errno — 返回一個包含當(dāng)前會話錯誤信息的數(shù)字編號
curl_error — 返回一個包含當(dāng)前會話錯誤信息的字符串
curl_exec — 執(zhí)行一個curl會話
curl_getinfo — 獲取一個curl連接資源句柄的信息
curl_init — 初始化一個curl會話
curl_multi_add_handle — 向curl批處理會話中添加單獨的curl句柄資源
curl_multi_close — 關(guān)閉一個批處理句柄資源
curl_multi_exec — 解析一個curl批處理句柄
curl_multi_getcontent — 返回獲取的輸出的文本流
curl_multi_info_read — 獲取當(dāng)前解析的curl的相關(guān)傳輸信息
curl_multi_init — 初始化一個curl批處理句柄資源
curl_multi_remove_handle — 移除curl批處理句柄資源中的某個句柄資源
curl_multi_select — Get all the sockets associated with the cURL extension, which can then be "selected"
curl_setopt_array — 以數(shù)組的形式為一個curl設(shè)置會話參數(shù)
curl_setopt — 為一個curl設(shè)置會話參數(shù)
curl_version — 獲取curl相關(guān)的版本信息

curl_init()函數(shù)的作用初始化一個curl會話,curl_init()函數(shù)唯一的一個參數(shù)是可選的,表示一個url地址。
curl_exec()函數(shù)的作用是執(zhí)行一個curl會話,唯一的參數(shù)是curl_init()函數(shù)返回的句柄。
curl_close()函數(shù)的作用是關(guān)閉一個curl會話,唯一的參數(shù)是curl_init()函數(shù)返回的句柄。

$ch = curl_init("http://www.baidu.com/");
curl_exec($ch);
curl_close($ch);
?>
curl_version()函數(shù)的作用是獲取curl相關(guān)的版本信息,curl_version()函數(shù)有一個參數(shù),不清楚是做什么的

print_r(curl_version())
?>
curl_getinfo()函數(shù)的作用是獲取一個curl連接資源句柄的信息,curl_getinfo()函數(shù)有兩個參數(shù),第一個參數(shù)是curl的資源句柄,第二個參數(shù)是下面一些常量:

$ch = curl_init("http://www.baidu.com/");
print_r(curl_getinfo($ch));
?>
可選的常量包括:

CURLINFO_EFFECTIVE_URL
最后一個有效的url地址

CURLINFO_HTTP_CODE
最后一個收到的HTTP代碼

CURLINFO_FILETIME
遠程獲取文檔的時間,如果無法獲取,則返回值為“-1”

CURLINFO_TOTAL_TIME
最后一次傳輸所消耗的時間

CURLINFO_NAMELOOKUP_TIME
名稱解析所消耗的時間

CURLINFO_CONNECT_TIME
建立連接所消耗的時間

CURLINFO_PRETRANSFER_TIME
從建立連接到準備傳輸所使用的時間

CURLINFO_STARTTRANSFER_TIME
從建立連接到傳輸開始所使用的時間

CURLINFO_REDIRECT_TIME
在事務(wù)傳輸開始前重定向所使用的時間

CURLINFO_SIZE_UPLOAD
上傳數(shù)據(jù)量的總值

CURLINFO_SIZE_DOWNLOAD
下載數(shù)據(jù)量的總值

CURLINFO_SPEED_DOWNLOAD
平均下載速度

CURLINFO_SPEED_UPLOAD
平均上傳速度

CURLINFO_HEADER_SIZE
header部分的大小

CURLINFO_HEADER_OUT
發(fā)送請求的字符串

CURLINFO_REQUEST_SIZE
在HTTP請求中有問題的請求的大小

CURLINFO_SSL_VERIFYRESULT
Result of SSL certification verification requested by setting CURLOPT_SSL_VERIFYPEER

CURLINFO_CONTENT_LENGTH_DOWNLOAD
從Content-Length: field中讀取的下載內(nèi)容長度

CURLINFO_CONTENT_LENGTH_UPLOAD
上傳內(nèi)容大小的說明

CURLINFO_CONTENT_TYPE
下載內(nèi)容的“Content-type”值,NULL表示服務(wù)器沒有發(fā)送有效的“Content-Type: header”

curl_setopt()函數(shù)的作用是為一個curl設(shè)置會話參數(shù)。curl_setopt_array()函數(shù)的作用是以數(shù)組的形式為一個curl設(shè)置會話參數(shù)。

$ch = curl_init();
$fp = fopen("example_homepage.txt", "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
$options = array(
CURLOPT_URL => 'http://www.baidu.com/',
CURLOPT_HEADER => false
);
curl_setopt_array($ch, $options);
curl_exec($ch);
curl_close($ch);
fclose($fp);
?>
可設(shè)置的參數(shù)有:

CURLOPT_AUTOREFERER
自動設(shè)置header中的referer信息

CURLOPT_BINARYTRANSFER
在啟用CURLOPT_RETURNTRANSFER時候?qū)@取數(shù)據(jù)返回

CURLOPT_COOKIESESSION
啟用時curl會僅僅傳遞一個session cookie,忽略其他的cookie,默認狀況下curl會將所有的cookie返回給服務(wù)端。session cookie是指那些用來判斷服務(wù)器端的session是否有效而存在的cookie。

CURLOPT_CRLF
啟用時將Unix的換行符轉(zhuǎn)換成回車換行符。

CURLOPT_DNS_USE_GLOBAL_CACHE
啟用時會啟用一個全局的DNS緩存,此項為線程安全的,并且默認為true。

CURLOPT_FAILONERROR
顯示HTTP狀態(tài)碼,默認行為是忽略編號小于等于400的HTTP信息

CURLOPT_FILETIME
啟用時會嘗試修改遠程文檔中的信息。結(jié)果信息會通過curl_getinfo()函數(shù)的CURLINFO_FILETIME選項返回。

CURLOPT_FOLLOWLOCATION
啟用時會將服務(wù)器服務(wù)器返回的“Location:”放在header中遞歸的返回給服務(wù)器,使用CURLOPT_MAXREDIRS可以限定遞歸返回的數(shù)量。

CURLOPT_FORBID_REUSE
在完成交互以后強迫斷開連接,不能重用。

CURLOPT_FRESH_CONNECT
強制獲取一個新的連接,替代緩存中的連接。

CURLOPT_FTP_USE_EPRT
TRUE to use EPRT (and LPRT) when doing active FTP downloads. Use FALSE to disable EPRT and LPRT and use PORT only.
Added in PHP 5.0.0.

CURLOPT_FTP_USE_EPSV
TRUE to first try an EPSV command for FTP transfers before reverting back to PASV. Set to FALSE to disable EPSV.

CURLOPT_FTPAPPEND
TRUE to append to the remote file instead of overwriting it.

CURLOPT_FTPASCII
An alias of CURLOPT_TRANSFERTEXT. Use that instead.

CURLOPT_FTPLISTONLY
TRUE to only list the names of an FTP directory.

CURLOPT_HEADER
啟用時會將頭文件的信息作為數(shù)據(jù)流輸出。

CURLOPT_HTTPGET
啟用時會設(shè)置HTTP的method為GET,因為GET是默認是,所以只在被修改的情況下使用。

CURLOPT_HTTPPROXYTUNNEL
啟用時會通過HTTP代理來傳輸。

CURLOPT_MUTE
講curl函數(shù)中所有修改過的參數(shù)恢復(fù)默認值。

CURLOPT_NETRC
在連接建立以后,訪問~/.netrc文件獲取用戶名和密碼信息連接遠程站點。

CURLOPT_NOBODY
啟用時將不對HTML中的body部分進行輸出。

CURLOPT_NOPROGRESS
啟用時關(guān)閉curl傳輸?shù)倪M度條,此項的默認設(shè)置為true

CURLOPT_NOSIGNAL
啟用時忽略所有的curl傳遞給php進行的信號。在SAPI多線程傳輸時此項被默認打開。

CURLOPT_POST
啟用時會發(fā)送一個常規(guī)的POST請求,類型為:application/x-www-form-urlencoded,就像表單提交的一樣。

CURLOPT_PUT
啟用時允許HTTP發(fā)送文件,必須同時設(shè)置CURLOPT_INFILE和CURLOPT_INFILESIZE

CURLOPT_RETURNTRANSFER
講curl_exec()獲取的信息以文件流的形式返回,而不是直接輸出。

CURLOPT_SSL_VERIFYPEER
FALSE to stop cURL from verifying the peer's certificate. Alternate certificates to verify against can be specified with the CURLOPT_CAINFO option or a certificate directory can be specified with the CURLOPT_CAPATH option. CURLOPT_SSL_VERIFYHOST may also need to be TRUE or FALSE if CURLOPT_SSL_VERIFYPEER is disabled (it defaults to 2). TRUE by default as of cURL 7.10. Default bundle installed as of cURL 7.10.

CURLOPT_TRANSFERTEXT
TRUE to use ASCII mode for FTP transfers. For LDAP, it retrieves data in plain text instead of HTML. On Windows systems, it will not set STDOUT to binary mode.

CURLOPT_UNRESTRICTED_AUTH
在使用CURLOPT_FOLLOWLOCATION產(chǎn)生的header中的多個locations中持續(xù)追加用戶名和密碼信息,即使域名已發(fā)生改變。

CURLOPT_UPLOAD
啟用時允許文件傳輸

CURLOPT_VERBOSE
啟用時會匯報所有的信息,存放在STDERR或指定的CURLOPT_STDERR中

CURLOPT_BUFFERSIZE
每次獲取的數(shù)據(jù)中讀入緩存的大小,這個值每次都會被填滿。

CURLOPT_CLOSEPOLICY
不是CURLCLOSEPOLICY_LEAST_RECENTLY_USED就是CURLCLOSEPOLICY_OLDEST,還存在另外三個,但是curl暫時還不支持。.

CURLOPT_CONNECTTIMEOUT
在發(fā)起連接前等待的時間,如果設(shè)置為0,則不等待。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to get the current session ID in PHP? How to get the current session ID in PHP? Jul 13, 2025 am 03:02 AM

The method to get the current session ID in PHP is to use the session_id() function, but you must call session_start() to successfully obtain it. 1. Call session_start() to start the session; 2. Use session_id() to read the session ID and output a string similar to abc123def456ghi789; 3. If the return is empty, check whether session_start() is missing, whether the user accesses for the first time, or whether the session is destroyed; 4. The session ID can be used for logging, security verification and cross-request communication, but security needs to be paid attention to. Make sure that the session is correctly enabled and the ID can be obtained successfully.

PHP get substring from a string PHP get substring from a string Jul 13, 2025 am 02:59 AM

To extract substrings from PHP strings, you can use the substr() function, which is syntax substr(string$string,int$start,?int$length=null), and if the length is not specified, it will be intercepted to the end; when processing multi-byte characters such as Chinese, you should use the mb_substr() function to avoid garbled code; if you need to intercept the string according to a specific separator, you can use exploit() or combine strpos() and substr() to implement it, such as extracting file name extensions or domain names.

How do you perform unit testing for php code? How do you perform unit testing for php code? Jul 13, 2025 am 02:54 AM

UnittestinginPHPinvolvesverifyingindividualcodeunitslikefunctionsormethodstocatchbugsearlyandensurereliablerefactoring.1)SetupPHPUnitviaComposer,createatestdirectory,andconfigureautoloadandphpunit.xml.2)Writetestcasesfollowingthearrange-act-assertpat

How to split a string into an array in PHP How to split a string into an array in PHP Jul 13, 2025 am 02:59 AM

In PHP, the most common method is to split the string into an array using the exploit() function. This function divides the string into multiple parts through the specified delimiter and returns an array. The syntax is exploit(separator, string, limit), where separator is the separator, string is the original string, and limit is an optional parameter to control the maximum number of segments. For example $str="apple,banana,orange";$arr=explode(",",$str); The result is ["apple","bana

JavaScript Data Types: Primitive vs Reference JavaScript Data Types: Primitive vs Reference Jul 13, 2025 am 02:43 AM

JavaScript data types are divided into primitive types and reference types. Primitive types include string, number, boolean, null, undefined, and symbol. The values are immutable and copies are copied when assigning values, so they do not affect each other; reference types such as objects, arrays and functions store memory addresses, and variables pointing to the same object will affect each other. Typeof and instanceof can be used to determine types, but pay attention to the historical issues of typeofnull. Understanding these two types of differences can help write more stable and reliable code.

Using std::chrono in C Using std::chrono in C Jul 15, 2025 am 01:30 AM

std::chrono is used in C to process time, including obtaining the current time, measuring execution time, operation time point and duration, and formatting analysis time. 1. Use std::chrono::system_clock::now() to obtain the current time, which can be converted into a readable string, but the system clock may not be monotonous; 2. Use std::chrono::steady_clock to measure the execution time to ensure monotony, and convert it into milliseconds, seconds and other units through duration_cast; 3. Time point (time_point) and duration (duration) can be interoperable, but attention should be paid to unit compatibility and clock epoch (epoch)

How to pass a session variable to another page in PHP? How to pass a session variable to another page in PHP? Jul 13, 2025 am 02:39 AM

In PHP, to pass a session variable to another page, the key is to start the session correctly and use the same $_SESSION key name. 1. Before using session variables for each page, it must be called session_start() and placed in the front of the script; 2. Set session variables such as $_SESSION['username']='JohnDoe' on the first page; 3. After calling session_start() on another page, access the variables through the same key name; 4. Make sure that session_start() is called on each page, avoid outputting content in advance, and check that the session storage path on the server is writable; 5. Use ses

PHP header location not working after include PHP header location not working after include Jul 13, 2025 am 02:08 AM

When encountering the problem that header('Location:...') does not work, the common reasons and solutions are as follows: 1. There is output in advance, causing the header to fail. The solution is to ensure that there is no output before the jump, including spaces, HTML or echo; 2. There is excess output or UTF-8 BOM characters in the include or require file. The file encoding should be checked and saved as "UTF-8 BOM-free"; 3. It is recommended to use ob_start() to turn on the output buffer before the jump, and cooperate with ob_end_flush() to delay the output; 4. After the jump, be sure to add exit to prevent subsequent code execution; 5. Make sure that the header() function call is before all outputs.

See all articles