【发布时间】:2014-03-21 09:37:04
【问题描述】:
我需要获取一个json文件的内容。
我用:
$message_path = 'path/to/message.json';
$data = file_get_contents("$message_path");
echo $data;
这里是message.json:
{
"message": "hello ${last_name} ${first_name}\nblabla",
"date": null,
"state": "DRAFT",
"externalUrl": null,
"landingPageType": "custom",
"landingPageTitle": null,
"sourceAddress": null,
"flash": false,
"type": 'STANDARD',
"scheduledType": "now"
}
这里是回声:
"{n "message": "hello ${last_name} ${first_name}nblabla",n "date": null,n "state": "DRAFT",n "externalUrl": null,n "landingPageType": "custom",n "landingPageTitle": null,n "sourceAddress": null,n "flash": false,n "type": 'STANDARD',n "scheduledType": "now"n}
为什么所有这些 'n' 字符?这个怎么去掉?
【问题讨论】:
标签: php json file-get-contents