首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > PHP >

怎么使用post提交json数据

2013-01-01 
如何使用post提交json数据如何使用php的post提交json数据...[解决办法]以下是一个例子,你可以按需扩展。$po

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

$post_data =   
            array(  
                    'name'=>'aaa',  
                    'age'=>45,  
            );  
  

    $url='http://www.example.com/example.php';  
  
    $ch = curl_init();  
    curl_setopt($ch, CURLOPT_POST, 1);  
    curl_setopt($ch, CURLOPT_URL,$url);  
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);  
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $result=curl_exec($ch);  
    echo $result;
 

热点排行