注意:如果这是一个非常简单的问题,我很抱歉,但我对代码的格式有点强迫.
我有一个类,其函数返回一个字符串,该字符串将构成电子邮件的正文.我希望这个文本格式化,以便它在电子邮件中看起来正确,但也因此它不会使我的代码看起来很时髦.这就是我的意思:
class Something
{
public function getEmailText($vars)
{
$text = 'Hello ' . $vars->name . ",
The second line starts two lines below.
I also don't want any spaces before the new line, so it's butted up against the left side of the screen.";
return $text;
}
}
Run Code Online (Sandbox Code Playgroud)
但它也可以写成:
public function getEmailText($vars)
{
$text = "Hello {$vars->name},\n\rThe second line starts two lines below.\n\rI also don't want any spaces before the new line, so it's butted up against the left …
Run Code Online (Sandbox Code Playgroud)