PHP引号当中关联数组变量的索引貌似不需要加引号
例如
$pop = array("0"=>"p1","1"=>"p2","2"=>"p3","3"=>"p4","a4"=>"p5","5"=>"p6","6"=>"p7","7"=>"p8","8"=>"p9");
echo json_encode(array('reward_code'=> 4 ,"pop"=>"$pop[a4]" ));
这是正确的
echo json_encode(array('reward_code'=> 4 ,"pop"=>"$pop['a4']" ));
这是错误的,报:
syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in
最后更新于 2017-03-17 15:58:08 并被添加「」标签,已有 577 位童鞋阅读过。
此处评论已关闭