2013-02-17 159 views
0

什麼是下面的CURL命令的PHP等效物?PHP等效的CURL命令

curl -X POST -d "html=<html><body><h1 style="color: red;">Hello World!</h1>" http://example.com/post"

+2

我們真的不是'適配器'。瞭解捲曲功能。 – Daric 2013-02-17 15:10:58

+0

請參閱[cURL文檔](http://www.php.net/manual/en/book.curl.php) – Gargron 2013-02-17 15:13:29

+1

兄弟,你甚至谷歌? – Romain 2013-02-17 15:13:36

回答

3

嘗試是這樣的:

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, 'http://example.com/post'); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($ch, CURLOPT_POST, true); 
$data = array('html' => '<html><body><h1 style="color: red;">Hello World!</h1>'); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 
$output = curl_exec($ch); 
curl_close($ch); 

以供將來參考,它會是有用的信息PHP's documentation,問這樣的問題之前偵察other examples