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

怎么使用post提交json数据

WBOY
Release: 2016-06-13 13:00:04
Original
1096 people have browsed it

如何使用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;
Copy after login
 

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template