这是因为您使用了双逗号而没有转义它们。替换此:
$content = "
The coupon code $coupon_code has been applied by a customer
";
使用此选项:
$content = "
The coupon code $coupon_code has been applied by a customer with
<p style="text-align: right; direction: rtl;">The coupon code
$coupon_code has been applied by a customer</p>
";
请注意,来自<;的双逗号<;style=“>>?这基本上关闭了用于定义$content变量的第一个双逗号<;$content=“>>”。基本上,php看到的$内容变量如下所示:
$content ="
The coupon code $coupon_code has been applied by a customer with
<p style="
这意味着php将尝试解释这一点:<<;文本对齐:右对齐;方向:rtl;>>作为php代码,它将返回一个致命错误,因为根据php,这是胡言乱语(而且,它不认为$content变量行以“;”结尾,这可能意味着它将返回类似“意外的‘t’在线…”“。
您必须通过在转义字符前面加“\\”来转义变量中的所有双逗号,如下所示:
$content = "
The coupon code $coupon_code has been applied by a customer with
<p style=\\"text-align: right; direction: rtl;\\">The coupon code
$coupon_code has been applied by a customer</p>
";
或选择单逗号:
$content = "
The coupon code $coupon_code has been applied by a customer with
<p style=\'text-align: right; direction: rtl;\'>The coupon code
$coupon_code has been applied by a customer</p>
";
我建议您开始更加熟悉php,这是一种非常简单的编程语言,您会发现许多教程和文档。您可能还想阅读此线程,以便更好地理解php中单逗号和双逗号之间的区别:
https://stackoverflow.com/questions/3446216/what-is-the-difference-between-single-quoted-and-double-quoted-strings-in-php