php接收post 的 json数据

直接I(“post.data”) 或 $_POST[‘data’] 不管用

windows环境下-- 用$GLOBALS[‘HTTP_RAW_POST_DATA’];

 	//接收到数据
 	$data = $GLOBALS['HTTP_RAW_POST_DATA'];
 	//json转数组
 	    $arr=json_decode(strip_tags($data),true);
 	//取值    
 	    $id = $arr['keyword'];
 	    $type= $arr['type'];
 	    $is_short =$arr['short'];

contos 环境下–用 file_get_contents(‘php://input’);

		$data = file_get_contents('php://input');      
	 	$jsonArr= json_decode($data,TRUE);	    
 
       	$id = $jsonArr['keyword'];
 	    $type=$jsonArr['type'];      
 	    $is_short=$jsonArr['short'];


版权声明:本文为xingnang2008原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。