|
- <?php
- error_reporting(0);
- $data=array();
- function object_to_array($obj)
- {
- $_arr= is_object($obj) ? get_object_vars($obj) : $obj;
- foreach($_arr as $key=> $val)
- {
- $val= (is_array($val) || is_object($val)) ? object_to_array($val) : $val;
- $arr[$key] = $val;
- }
- return $arr;
- }
- $ary=array();
- if (empty($_POST)){
- $content = file_get_contents('php://input');
- $ary = (array)json_decode($content, true);
- $data["msg"]="OK1...".var_export($ary,true);
- } else {
- $ary=object_to_array($_POST);
- $data["msg"]="OK2...".var_export($ary,true);
- }
-
- header('Content-type: text/json; charset=utf-8');
- echo json_encode($data,JSON_UNESCAPED_UNICODE);
复制代码
|
|