日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

json php input,在php中读取json输入

發布時間:2023/12/1 php 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 json php input,在php中读取json输入 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

php://輸入在localhost中正常工作.但在服務器中它返回空.

輸入(請求)到我的站點是一個json(REST – 應用程序/ json類型),所以$_POST不起作用(請閱讀

This question).

$_POST works with key-value pair type inputs like form-data or x-www-urlencoded

key1=value1&key2=value2&key3=value3

我正在使用application / json作為輸入(在REST中).

Like {‘key1′:’value1′,’key2′:’value2′,’key3′:’value3’}

使用$_POST無法處理此問題.但是使用php://輸入可以幫助讀取該數據.

我的代碼

class Webservice_Controller extends CI_Controller {

public $json_input_data;

public function __construct(){

parent::__construct();

$this->json_input_data = json_decode(file_get_contents('php://input'),TRUE);

}

public function json_input($label){

if(isset($this->json_input_data[$label])) return $this->json_input_data[$label];

else return NULL;

}

}

上面的代碼在另一個網絡服務器上工作正常,但不是在當前的. 🙁

我認為我的Web服務器拒絕訪問php:// input.

Is there is any other methods to read json input in php ?

總結

以上是生活随笔為你收集整理的json php input,在php中读取json输入的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。