2013-02-17 128 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