【问题标题】:PHP Equivalent of CURL commandCURL 命令的 PHP 等效项
【发布时间】:2013-02-02 01:35:59
【问题描述】:

以下 CURL 命令的 PHP 等效项是什么?

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

【问题讨论】:

  • 我们真的不是adapters。学习 curl 函数。
  • 兄弟,你也google吗?

标签: php http curl


【解决方案1】:

试试这样的:

$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 会很有用。

【讨论】:

    猜你喜欢
    • 2013-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多