与CURL命令等效的PHP

与CURL命令等效的PHP,php,http,curl,Php,Http,Curl,以下CURL命令的PHP等价物是什么 curl-xpost-d“html=helloworld!”http://example.com/post“试试这样的方法: $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

以下CURL命令的PHP等价物是什么


curl-xpost-d“html=helloworld!”http://example.com/post“

试试这样的方法:

$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);
$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'=>'Hello World!');
curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
$output=curl\u exec($ch);
卷曲关闭($ch);

为了便于将来参考,在提出这类问题之前先阅读并仔细研究一下是很有用的。

尝试以下方法:

$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);
$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'=>'Hello World!');
curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
$output=curl\u exec($ch);
卷曲关闭($ch);

作为将来的参考,在提出这类问题之前,阅读并找出答案是很有用的。

我们真的不是
适配器
。学习curl函数。参考Bro,你甚至谷歌了吗?我们真的不是
适配器
。学习curl函数。参考Bro,你甚至谷歌了吗?