-PHP curl中的w选项?

-PHP curl中的w选项?,php,Php,我正在将curlshell命令转换为PHP curl会话。 我有-o numl和-w“@curl format.txt”。 对于-o,我正在使用curl\u setopt($ch,CURLOPT\u文件,NULL) 但是,我找不到-w选项的curlpot。 我有 我需要将这些转换为PHP curl会话。 我的做法是: $ch = curl_init($url); $formatfile=fopen(curl-format.txt,"r");

我正在将curlshell命令转换为PHP curl会话。 我有-o numl和-w“@curl format.txt”。 对于-o,我正在使用curl\u setopt($ch,CURLOPT\u文件,NULL) 但是,我找不到-w选项的curlpot。 我有

我需要将这些转换为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\u exec($ch)
之后,您可以使用
curl\u getinfo($ch,CURLINFO*)
返回
CURLINFO.*
常量的值


您正在寻找-w返回的特定信息吗?curl_getinfo($ch),其中$ch是您的curl实例将返回一个数组,其中一些信息与-w选项相同,不确定它是否包含您需要的所有信息。请澄清您的问题。添加一个您正在使用的示例shell代码,这样我们可以更好地了解您需要什么,并帮助您实现所需的内容。“@curl-format.txt”是包含在curl会话之后要编写的格式的文件。我是否应该只写CLI
curl
用于替换
-w
格式中的变量的值由函数返回。
            $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);
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()