示例代码:

<?php
// 获取输入的内容
$request = http_get_request_body();

// 按json格式解析成一个 php对象
$json_obj = json_decode($request);

// 按json格式解析成一个 php关联数组
$json_obj_array = json_decode($request, true);


//var_dump($json_obj);

array_push($json_obj_array, "time", time());
echo json_encode($json_obj_array);
?>

注意: http_get_request_body() 属于 pecl_http 模块,需要额外安装(类似的函数还有http_get(), http_head() ...)

相关文章:

  • 2021-09-24
  • 2021-08-13
  • 2022-01-31
  • 2021-12-26
  • 2022-12-23
  • 2022-12-23
  • 2022-02-27
  • 2022-12-23
猜你喜欢
  • 2022-01-24
  • 2021-07-23
  • 2021-06-10
  • 2021-07-06
相关资源
相似解决方案