我试图在另一个页面上做一个简单的帖子,但没有数据发布。谁知道什么是错的?
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,"http://example.com/test.php");
curl_setopt($ch,CURLOPT_POST,true);
curl_setopt($ch,CURLOPT_POSTFIELDS,"one=val");
curl_setopt($ch,CURLOPT_HEADER,true);
curl_setopt($ch,CURLINFO_HEADER_OUT,true);
$result = curl_exec($ch);
echo print_r($result,true);
echo print_r(curl_getinfo($ch),true);
导致:
(
[url] => http://example.com/test.php
[content_type] =>
[http_code] => 0
[header_size] => 0
[request_size] => 0
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0
[namelookup_time] => 0
[connect_time] => 0
[pretransfer_time] => 0
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => -1
[upload_content_length] => -1
[starttransfer_time] => 0
[redirect_time] => 0
[certinfo] => Array
(
)
[redirect_url] =>
)
标题也不会打印出来。