Home >Backend Development >PHP Tutorial > 怎么使用post提交json数据

怎么使用post提交json数据

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-13 13:00:041131browse

如何使用post提交json数据
如何使用php的post提交json数据...
------解决方案--------------------
以下是一个例子,你可以按需扩展。

$post_data =   <br />
            array(  <br />
                    'name'=>'aaa',  <br />
                    'age'=>45,  <br />
            );  <br />
  <br />
<br />
    $url='http://www.example.com/example.php';  <br />
  <br />
    $ch = curl_init();  <br />
    curl_setopt($ch, CURLOPT_POST, 1);  <br />
    curl_setopt($ch, CURLOPT_URL,$url);  <br />
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);  <br />
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);<br />
    $result=curl_exec($ch);  <br />
    echo $result;
 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn