PHP的双引号和单引号的区别:单引号就是绝对的字符串,双引号中的变量可以解析
单引号(控制台输出):
$content = sprintf('%s\n%s\n%s\n%s\n%s\n',
$appid,
$serialNo,
$timeStamp,
$nonceStr,
$encryptedData
);
string(626) "OP00000003\n00dfba8194c41b84cf\n1716360777\nQAD3qK75q1JgoqJC8nnfFRHxkpCEHas4\n{
"req_time": "20210907150256",
"version": "3.0",
"out_org_code": "OP00000003",
"req_data": {
"merchant_no": "822290070111135",
"trans_type": "71",
"term_no": "29034705",
"out_trade_no": "FD660E1FAA3A4470933CDEDAE1EC1D8E",
"auth_code": "135178236713755038",
"total_amount": "123",
"location_info": {
"request_ip": "10.176.1.192",
"location": "+37.123456789,-121.123456789"
},
"out_order_no": "08F4542EEC6A4497BC419161747A92FA"
}
}\n"
双引号(控制台输出):
$content = sprintf("%s\n%s\n%s\n%s\n%s\n",
$appid,
$serialNo,
$timeStamp,
$nonceStr,
$encryptedData
);
string(621) "OP00000003
00dfba8194c41b84cf
1716360777
QAD3qK75q1JgoqJC8nnfFRHxkpCEHas4
{
"req_time": "20210907150256",
"version": "3.0",
"out_org_code": "OP00000003",
"req_data": {
"merchant_no": "822290070111135",
"trans_type": "71",
"term_no": "29034705",
"out_trade_no": "FD660E1FAA3A4470933CDEDAE1EC1D8E",
"auth_code": "135178236713755038",
"total_amount": "123",
"location_info": {
"request_ip": "10.176.1.192",
"location": "+37.123456789,-121.123456789"
},
"out_order_no": "08F4542EEC6A4497BC419161747A92FA"
}
}
"