簡體   English   中英

PHP curl中的-w選項?

[英]-w option in PHP curl?

我正在將curl shell命令轉換為PHP curl會話。 我有-o NUL和-w“ @ curl-format.txt”。 對於-o,我正在使用curl_setopt($ ch,CURLOPT_FILE,NULL)但是,我找不到用於-w選項的CURLOPT。 我有

      $cmd = "curl -w \"@curl-format.txt\" -o NUL -s \"".$url."\"";

      $output = shell_exec($cmd);

我需要將它們轉換為PHP curl會話。 我做的像:

            $ch = curl_init($url);

            $formatfile=fopen(curl-format.txt,"r");   

            curl_setopt($ch,CURLOPT_FILE,NULL);

            curl_setopt($ch,CURLOPT_RETURNTRANSFER ,TRUE);

            curl_exec($ch); 

            curl_close($ch);

我應該為-w做些什么?

curl_exec($ch)您可以使用curl_getinfo($ch, CURLINFO_*); 返回CURLINFO_*常量的值。

http://php.net/manual/zh/function.curl-getinfo.php

This may be one of the following constants:

CURLINFO_EFFECTIVE_URL - Last effective URL
CURLINFO_HTTP_CODE - Last received HTTP code
CURLINFO_FILETIME - Remote time of the retrieved document, if -1 is returned the time of the document is unknown
CURLINFO_TOTAL_TIME - Total transaction time in seconds for last transfer
CURLINFO_NAMELOOKUP_TIME - Time in seconds until name resolving was complete
CURLINFO_CONNECT_TIME - Time in seconds it took to establish the connection
CURLINFO_PRETRANSFER_TIME - Time in seconds from start until just before file transfer begins
CURLINFO_STARTTRANSFER_TIME - Time in seconds until the first byte is about to be transferred
CURLINFO_REDIRECT_COUNT - Number of redirects, with the CURLOPT_FOLLOWLOCATION option enabled
CURLINFO_REDIRECT_TIME - Time in seconds of all redirection steps before final transaction was started, with the CURLOPT_FOLLOWLOCATION option enabled
CURLINFO_REDIRECT_URL - With the CURLOPT_FOLLOWLOCATION option disabled: redirect URL found in the last transaction, that should be requested manually next. With the CURLOPT_FOLLOWLOCATION option enabled: this is empty. The redirect URL in this case is available in CURLINFO_EFFECTIVE_URL
CURLINFO_PRIMARY_IP - IP address of the most recent connection
CURLINFO_PRIMARY_PORT - Destination port of the most recent connection
CURLINFO_LOCAL_IP - Local (source) IP address of the most recent connection
CURLINFO_LOCAL_PORT - Local (source) port of the most recent connection
CURLINFO_SIZE_UPLOAD - Total number of bytes uploaded
CURLINFO_SIZE_DOWNLOAD - Total number of bytes downloaded
CURLINFO_SPEED_DOWNLOAD - Average download speed
CURLINFO_SPEED_UPLOAD - Average upload speed
CURLINFO_HEADER_SIZE - Total size of all headers received
CURLINFO_HEADER_OUT - The request string sent. For this to work, add the CURLINFO_HEADER_OUT option to the handle by calling curl_setopt()
CURLINFO_REQUEST_SIZE - Total size of issued requests, currently only for HTTP requests
CURLINFO_SSL_VERIFYRESULT - Result of SSL certification verification requested by setting CURLOPT_SSL_VERIFYPEER
CURLINFO_CONTENT_LENGTH_DOWNLOAD - content-length of download, read from Content-Length: field
CURLINFO_CONTENT_LENGTH_UPLOAD - Specified size of upload
CURLINFO_CONTENT_TYPE - Content-Type: of the requested document, NULL indicates server did not send valid Content-Type: header
CURLINFO_PRIVATE - Private data associated with this cURL handle, previously set with the CURLOPT_PRIVATE option of curl_setopt()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM