我试图从cookie中解析JSON编码的字符串,当我在字符串上运行json_decode()时,它返回为null。这应该是一个简单的操作 - 我错过了什么?
/* Get */
$cookie_exampleData = $_COOKIE['exmaple_data'];
// Retrieves: '{\"FirstName\":\"Angus\",\"LastName\":\"MacGyver\",\"Email\":\"hello@email.com\",\"Phone\":\"8185555555\"}'
/* Decode */
$cookie_exampleData_decoded = json_decode($cookie_exampleData);
/* Print */
var_dump($cookie_exampleData_decoded);
// Returns: NULL
答案 0 :(得分:4)