Reading json input in php

后端 未结 2 1745
一整个雨季
一整个雨季 2020-12-11 03:40

php://input is working properly in localhost. But in server it returns empty. Input( request ) to my site is a json(REST - application/json typ

2条回答
  •  渐次进展
    2020-12-11 04:08

    I know this is old, but it might help others:

    Careful with single quotes inside your json

    From the PHP documentation about json_decode:

    the name and value must be enclosed in double quotes
    single quotes are not valid 
    
    $bad_json = "{ 'bar': 'baz' }";
    json_decode($bad_json); // null
    

提交回复
热议问题