Php 在JSon中添加变量不起作用
我正在尝试在json变量中添加变量,然后尝试发送电子邮件我得到的是变量而不是变量值请查看:Php 在JSon中添加变量不起作用,php,json,Php,Json,我正在尝试在json变量中添加变量,然后尝试发送电子邮件我得到的是变量而不是变量值请查看: $request_json = '{ "type":"messages", "call":"send", "message":{ "html":"$salesmsgUpdatemsg", }'; $request_json = '{ "type":"messa
$request_json = '{
"type":"messages",
"call":"send",
"message":{
"html":"$salesmsgUpdatemsg",
}';
$request_json = '{
"type":"messages",
"call":"send",
"message":{
"html":"'.$salesmsgUpdatemsg.'",
}';
如果我使用,两个代码都不起作用
$request_json = '{
"type":"messages",
"call":"send",
"message":{
"html":"Content Text",
}';
工作正常
不知道会发生什么
谢谢你应该遵守,因为总有一天你的代码会被破解
$request = array ('type'=>"messages",
'call'=>'send',
'message'=>array(
'html'=>$salesmsgUpdatemsg
));
$request_json = json_encode($request);
您不应该手动构建json。按照您想要的方式构建数组/对象并使用
json\u encode()
。但是它是mandrill JsonFirst,带有单引号的数组/对象不会插入PHP变量。如果变量包含双引号怎么办?这将破坏您的json。我已经尝试使用双引号