Php 有没有办法解决这个Sprintf问题

Php 有没有办法解决这个Sprintf问题,php,html,Php,Html,我有这段代码,它工作得很好,但在代码行后剪切了消息: message=Sprintf("<p>Dear user,<br /> Your request have been initiated from your Account. Enter your code <br /><br /> Your Code is: %u", $data['code'], ==============================================

我有这段代码,它工作得很好,但在代码行后剪切了消息:

message=Sprintf("<p>Dear user,<br />
Your request have been initiated from your Account. Enter your code <br /><br />
Your Code is: %u", $data['code'], 
================================================Doesn't send this part below
"Your Code will expire in 30 minutes, 
Thank you for choosing Industrial Bank, we are determined to making life better for you.<br />
<br /><br />
Regards,<br />
Apptix<br />
")
我试着用有问题的部分创建另一个变量

message=Sprintf("<p>Dear user,<br />
Your  transfer request have been initiated from your Private Account. Enter your code <br /><br />
Your Code is: %u", $data['code'] <br /> <br /> 
"Your Code will expire in 30 minutes, 
Thank you for choosing Industrial Bank, we are determined to making life better for you.<br />
<br /><br />
Regards,<br />
Apptix<br />
")

sprintf的第一个参数是字符串模板。您试图使用两个单独的模板,但这不起作用。你有:

sprintf('template 1', $data['code'], 'template 2');
你想要:

sprintf('template 1 template 2', $data['code']);
或许:

sprintf('template 1', $data['code']) . 'template2';
用美元符号初始化变量 使用sprintf函数而不是sprintf 使用%s代替%s表示字符串 你不需要逗号 $data


在此之后,$message变量将有$data['code']内容代替%s

PHP变量以美元符号开头…PHP命令以分号结尾…您的使用无效。单击链接查看如何使用它。只需使用echo。。。或字符串串联。
$mesage = sprintf("<p>Dear user,<br />
Your request have been initiated from your Account. Enter your code <br /><br />
Your Code is: %s", $data['code']);
// output  $message
echo $mesage;