簡體   English   中英

PHP json_decode在對象GET變量上不起作用

[英]PHP json_decode not working on Object GET Variables

我有一個使用jsonp的角度代碼。 在我的參數中,我有一個對象變量'o_params'

JavaScript的

$http({
            method: 'JSONP', 
            url: "site_url/create-order-app",
            params: {
                'callback'              : 'JSON_CALLBACK',
                'avoidCache'            : Date.now(),
                'o_params'              : {"test":"test"} //properly formatted object
            }
    })

在PHP中,json_decode($ _ GET ['o_params'])產生null。 當我在php中檢查我的o_params時,似乎我的對象現在沒有正確格式化。 是因為GET而不是POST?

如何在PHP中正確解碼我的o_params?

你也可以在你的php文件上試試這個,並獲取你的參數:

$params = json_decode(file_get_contents('php://input'),true);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM