为什么newline转义序列没有转换为换行符?

时间:2010-05-03 21:07:14

标签: php email codeigniter escaping

我正在尝试使用codeigniter发送电子邮件,并希望邮件跨越多行。

$address = $this->input->post('email');
$subject = 'Please complete your registration';
$message = 'Thanks for registering! \n To complete your registration, please click on (or copy and paste in your browser) the following link: ' . base_url(). "users/confirmRegistration/" . $confirmation_code; //note the '\n' after thanks for registering

$this->load->library('email');
    $this->email->from('me@mysite.com', 'myname');
    $this->email->to($address); 
    $this->email->subject($subject);
    $this->email->message($message);    
    $this->email->send();

我希望邮件在“感谢注册”之后以换行符到达,但我得到了

  

感谢您的注册! ñ完成注册(等等......)

我尝试过\ r \ n但结果几乎相同:

  

感谢您的注册!要完成(等等)。这就像应用了striplash函数..

有什么想法吗?

2 个答案:

答案 0 :(得分:17)

PHP不会在单引号内解析\n之类的转义序列。

您需要将消息字符串括在双引号中。

答案 1 :(得分:-1)

您需要以此格式输入正文。 它工作正常。 拉胡

$ body ='亲爱的'。 $ row-> fname。 ''。 $ row-> lname。 ','。 “

'。 “您与我们的帐户已被暂时停用。” 。 “

'。 “我们的协调人关系团队将尽快与您联系。” 。 “

'。 “您也可以通过info@ggg.com与我们联系。” “

'。 '温暖的问候, ' 。 “

'。 '团队';

相关问题