【发布时间】:2016-09-29 20:51:20
【问题描述】:
第 1 个人输入数据,数据数组如下所示:
{
"type": "1",
"name": "John",
"phone":"898171"
}
人 2 没有设置电话,数据数组如下所示:
{
"type": "1",
"name": "Lisa"
} // only write 2 array...
我的控制器中有这样的源代码:
$data = json_decode(file_get_contents('php://input'), true);
if(!$data['phone']->iSEmpty){
echo "you haven't set the phone number!"
}
但这不起作用。第 2 个人输入数据时出现以下错误 -
“未定义索引:电话”
【问题讨论】: